From ac4ac95082a9ff69cda8ebee4419eda89a14342d Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Fri, 23 Oct 2026 18:44:03 +0300 Subject: [PATCH] Keep scroll position when picking a weapon on the front page --- app/components/WeaponPoolBanner.tsx | 3 +++ app/components/layout/SearchResults.tsx | 5 ++++- app/features/front-page/routes/index.tsx | 1 + changelog/2026-10-23-front-page-weapon-pool-scroll.md | 4 ++++ 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 changelog/2026-10-23-front-page-weapon-pool-scroll.md 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}