diff --git a/app/components/WeaponPoolBanner.tsx b/app/components/WeaponPoolBanner.tsx index b90253533..c4cf3909f 100644 --- a/app/components/WeaponPoolBanner.tsx +++ b/app/components/WeaponPoolBanner.tsx @@ -11,12 +11,14 @@ type WeaponPoolBannerTarget = | { weaponHref: (weaponId: MainWeaponId) => string; defaultShouldRevalidate?: boolean; + preventScrollReset?: boolean; onWeaponPress?: never; } | { onWeaponPress: (weaponId: MainWeaponId) => void; weaponHref?: never; defaultShouldRevalidate?: never; + preventScrollReset?: never; }; /** Highlighted row of quick links (or quick picks) to the weapons of the user's match profile weapon pool. */ @@ -73,6 +75,7 @@ export function WeaponPoolBanner({ key={weaponId} to={target.weaponHref(weaponId)} defaultShouldRevalidate={target.defaultShouldRevalidate} + preventScrollReset={target.preventScrollReset} className={styles.weapon} > {image} diff --git a/app/components/layout/SearchResults.tsx b/app/components/layout/SearchResults.tsx index 8823050d7..c21a19e9e 100644 --- a/app/components/layout/SearchResults.tsx +++ b/app/components/layout/SearchResults.tsx @@ -70,7 +70,10 @@ export function SearchResultsListBox({ ref.current = element; } if (element && autoFocus === "first") { - element.querySelector('[role="option"]')?.focus(); + // the parent dialog isn't open yet when this ref attaches, so a plain focus would scroll the page to it + element + .querySelector('[role="option"]') + ?.focus({ preventScroll: true }); } }} role="listbox" diff --git a/app/features/front-page/routes/index.tsx b/app/features/front-page/routes/index.tsx index 44cec7b6d..759c93281 100644 --- a/app/features/front-page/routes/index.tsx +++ b/app/features/front-page/routes/index.tsx @@ -357,6 +357,7 @@ function DiscoverFeatures() { }) } defaultShouldRevalidate={false} + preventScrollReset /> ) : null}