From 0fae97a189a68cfe4becc394c0a788f46add896b Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Tue, 24 Mar 2026 19:56:44 +0200 Subject: [PATCH] Make GlobalSearch actual links so we can ctrl+click for new tab --- app/components/layout/GlobalSearch.module.css | 7 +++ app/components/layout/GlobalSearch.tsx | 45 +++++++++---------- app/components/layout/WeaponSearch.tsx | 44 ++++++++++++++---- 3 files changed, 65 insertions(+), 31 deletions(-) diff --git a/app/components/layout/GlobalSearch.module.css b/app/components/layout/GlobalSearch.module.css index 57b96c4cc..6cac80f0d 100644 --- a/app/components/layout/GlobalSearch.module.css +++ b/app/components/layout/GlobalSearch.module.css @@ -131,11 +131,18 @@ } .listBoxItem { + display: block; padding: var(--s-2) var(--s-3); border-radius: var(--radius-field); cursor: pointer; font-size: var(--font-sm); outline: none; + color: inherit; + text-decoration: none; +} + +.listBoxItem[data-hovered] { + background-color: var(--color-bg-high); } .listBoxItem[data-focused] { diff --git a/app/components/layout/GlobalSearch.tsx b/app/components/layout/GlobalSearch.tsx index d51498dfd..810d5ec27 100644 --- a/app/components/layout/GlobalSearch.tsx +++ b/app/components/layout/GlobalSearch.tsx @@ -13,7 +13,7 @@ import { RadioGroup, } from "react-aria-components"; import { useTranslation } from "react-i18next"; -import { useFetcher, useNavigate, useSearchParams } from "react-router"; +import { useFetcher, useSearchParams } from "react-router"; import { useDebounce } from "react-use"; import { Avatar } from "~/components/Avatar"; import { Image } from "~/components/Image"; @@ -33,10 +33,8 @@ import styles from "./GlobalSearch.module.css"; import { filterWeaponResults, getRecentWeapons, - getWeaponDestinationUrl, type SelectedWeapon, saveRecentWeapon, - type WeaponDestination, WeaponDestinationMenu, WeaponResultsList, } from "./WeaponSearch"; @@ -182,7 +180,6 @@ function GlobalSearchContent({ initialWeaponId: string | null; }) { const { t } = useTranslation(["common", "weapons"]); - const navigate = useNavigate(); const [query, setQuery] = React.useState(""); const [searchType, setSearchType] = React.useState( initialSearchType ?? getInitialSearchType(), @@ -193,6 +190,11 @@ function GlobalSearchContent({ ); const inputRef = React.useRef(null); const listBoxRef = React.useRef(null); + const modifierKeyRef = React.useRef(false); + + const handleClickCapture = (e: React.MouseEvent) => { + modifierKeyRef.current = e.metaKey || e.ctrlKey; + }; const fetcher = useFetcher(); @@ -254,9 +256,7 @@ function GlobalSearchContent({ return; } - const result = results.find((r) => getResultKey(r) === key); - if (result) { - navigate(getResultHref(result)); + if (!modifierKeyRef.current) { onClose(); } }; @@ -274,16 +274,13 @@ function GlobalSearchContent({ } }; - const handleDestinationSelect = (key: React.Key) => { + const handleDestinationSelect = () => { if (!selectedWeapon) return; - const url = getWeaponDestinationUrl( - key as WeaponDestination, - selectedWeapon, - ); saveRecentWeapon(selectedWeapon.id); - navigate(url); - onClose(); + if (!modifierKeyRef.current) { + onClose(); + } }; const handleBackToWeaponSearch = () => { @@ -292,17 +289,19 @@ function GlobalSearchContent({ if (searchType === "weapons" && selectedWeapon) { return ( - +
+ +
); } return ( - <> +
hasQuery ? ( @@ -371,6 +369,7 @@ function GlobalSearchContent({ @@ -378,7 +377,7 @@ function GlobalSearchContent({ ))} )} - +
); } diff --git a/app/components/layout/WeaponSearch.tsx b/app/components/layout/WeaponSearch.tsx index f3a460589..972fd5c4e 100644 --- a/app/components/layout/WeaponSearch.tsx +++ b/app/components/layout/WeaponSearch.tsx @@ -86,7 +86,7 @@ export function filterWeaponResults( return matches; } -export function getWeaponDestinationUrl( +function getWeaponDestinationUrl( key: WeaponDestination, weapon: SelectedWeapon, ): string { @@ -145,7 +145,11 @@ export function WeaponDestinationMenu({ onAction={onSelect} autoFocus="first" > - +
@@ -153,7 +157,11 @@ export function WeaponDestinationMenu({
- +
@@ -161,7 +169,11 @@ export function WeaponDestinationMenu({
- +
@@ -169,7 +181,11 @@ export function WeaponDestinationMenu({
- +
@@ -177,19 +193,31 @@ export function WeaponDestinationMenu({
- +
{t("common:pages.vods")}
- +
{t("common:pages.art")}
- +
{t("common:pages.lfg")}