mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-27 04:54:25 -05:00
Keep scroll position when picking a weapon on the front page
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -70,7 +70,10 @@ export function SearchResultsListBox({
|
||||
ref.current = element;
|
||||
}
|
||||
if (element && autoFocus === "first") {
|
||||
element.querySelector<HTMLElement>('[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<HTMLElement>('[role="option"]')
|
||||
?.focus({ preventScroll: true });
|
||||
}
|
||||
}}
|
||||
role="listbox"
|
||||
|
||||
@@ -357,6 +357,7 @@ function DiscoverFeatures() {
|
||||
})
|
||||
}
|
||||
defaultShouldRevalidate={false}
|
||||
preventScrollReset
|
||||
/>
|
||||
) : null}
|
||||
<nav className={styles.discoverGrid}>
|
||||
|
||||
4
changelog/2026-10-23-front-page-weapon-pool-scroll.md
Normal file
4
changelog/2026-10-23-front-page-weapon-pool-scroll.md
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
type: bug
|
||||
---
|
||||
Clicking a weapon under "Your weapons" on the front page no longer scrolls the page to the top
|
||||
Reference in New Issue
Block a user