Skip to content

Commit 3fc96d9

Browse files
committed
docs(app): clarify RootLayout scroll-reset comment
scrollRestoration only affects POP navigation, not PUSH/REPLACE. The real reason for window.scrollTo(0, 0) is that SPA route transitions inherently keep the previous scroll position. Update the comment to state that, and stop singling out PlotsPage since HomePage also sets scrollRestoration.
1 parent 5328a66 commit 3fc96d9

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

app/src/components/RootLayout.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ export function RootLayout() {
2727
const navigationType = useNavigationType();
2828
const mastheadSticks = pathname !== '/plots';
2929

30-
// Reset scroll on forward navigation (PUSH/REPLACE). Without this, short
31-
// pages like /legal inherit the previous page's scroll position because
32-
// PlotsPage sets scrollRestoration='manual'. Skip on POP so browser
33-
// back/forward keeps native scroll restoration; skip when a hash anchor
34-
// is present so in-page anchors still work. PlotsPage runs its own
35-
// saved-scroll restore in a later effect, so it still overrides this.
30+
// Reset scroll on forward navigation (PUSH/REPLACE). In SPA route changes,
31+
// the next page can otherwise keep the previous page's scroll position,
32+
// which is especially noticeable on short pages like /legal. Skip on POP
33+
// so browser back/forward keeps native scroll restoration; skip when a
34+
// hash anchor is present so in-page anchors still work. Pages with their
35+
// own saved-scroll restore in a later effect can still override this.
3636
useEffect(() => {
3737
if (hash) return;
3838
if (navigationType === 'POP') return;

0 commit comments

Comments
 (0)