Skip to content

Preserve docs nav scroll position after page change - #732

Merged
mattrothenberg merged 2 commits into
mainfrom
pmenezes/preserve-docs-nav-scroll
Aug 17, 2026
Merged

Preserve docs nav scroll position after page change#732
mattrothenberg merged 2 commits into
mainfrom
pmenezes/preserve-docs-nav-scroll

Conversation

@pedromenezes1

@pedromenezes1 pedromenezes1 commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Preserve docs navigation scroll position across client-side page transitions.

Screen.Recording.2026-08-16.at.16.47.30.mov

  • Reviews
  • automated review not possible because: no automated code-review tooling was used
  • Tests
  • Additional testing not necessary because: focused lint and diff checks passed; browser validation was intentionally not performed

@pedromenezes1 pedromenezes1 changed the title Restore docs nav scroll after page transitions Preserve docs nav scroll position after page change Aug 16, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 16, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@cloudflare/kumo@732

commit: bf9a982

@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Docs Preview

View docs preview

Commit: d60916d

@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor
Visual Regression Report — 25 changed, 18 unchanged

25 screenshot(s) with visual changes:

Button / Variant: Ghost

175 px (0.2%) changed

Before After Diff
Before After Diff

Button / Icon Only

112 px (0.13%) changed

Before After Diff
Before After Diff

Button / Loading State

25 px (0.03%) changed

Before After Diff
Before After Diff

Button / Title

1,288 px (1.45%) changed

Before After Diff
Before After Diff

Button / Link with Tooltip

724 px (0.82%) changed

Before After Diff
Before After Diff

Dialog / Dialog With Actions

401 px (0.45%) changed

Before After Diff
Before After Diff

Dialog / Dialog Basic

316 px (0.36%) changed

Before After Diff
Before After Diff

Dialog / Dialog Alert

1,321 px (1.49%) changed

Before After Diff
Before After Diff

Dialog / Dialog Confirmation

1,498 px (1.69%) changed

Before After Diff
Before After Diff

Dialog / Custom Max Width

1,013 px (1.14%) changed

Before After Diff
Before After Diff

Dialog / Dialog With Combobox

480 px (0.54%) changed

Before After Diff
Before After Diff

Dialog (Open)

0 px (0%) changed

Before After Diff
Before After Diff

Select / Select Basic

1,243 px (1.4%) changed

Before After Diff
Before After Diff

Select / Select Without Label

573 px (0.65%) changed

Before After Diff
Before After Diff

Select / Select With Error

1,979 px (1.9%) changed

Before After Diff
Before After Diff

Select / Select Placeholder

1,234 px (1.39%) changed

Before After Diff
Before After Diff

Select / Select With Tooltip

1,062 px (1.2%) changed

Before After Diff
Before After Diff

Select / Select Custom Rendering

1,076 px (1.21%) changed

Before After Diff
Before After Diff

Select / Select Loading

2,110 px (1.2%) changed

Before After Diff
Before After Diff

Select / Select Complex

1,279 px (1.23%) changed

Before After Diff
Before After Diff

Select / Select Disabled Items

103 px (0.12%) changed

Before After Diff
Before After Diff

Select / Select Grouped

968 px (1.09%) changed

Before After Diff
Before After Diff

Select / Select Grouped With Disabled

1,478 px (1.67%) changed

Before After Diff
Before After Diff

Select / Select Long List

1,967 px (1.89%) changed

Before After Diff
Before After Diff

Select (Open)

1,082 px (0%) changed

Before After Diff
Before After Diff
18 screenshot(s) unchanged
  • Button / Basic
  • Button / Variant: Primary
  • Button / Variant: Secondary
  • Button / Variant: Destructive
  • Button / Variant: Outline
  • Button / Variant: Secondary Destructive
  • Button / Sizes
  • Button / With Icon
  • Button / Disabled State
  • Button / Link as Button
  • Button / Disabled Link
  • Dialog / Dialog Sizes
  • Dialog / Dialog With Select
  • Dialog / Dialog With Dropdown
  • Select / Select Sizes
  • Select / Select With Description
  • Select / Select Multiple
  • Select / Select Disabled Options

Generated by Kumo Visual Regression

@pedromenezes1
pedromenezes1 marked this pull request as ready for review August 16, 2026 16:00
@pedromenezes1

Copy link
Copy Markdown
Collaborator Author

/bonk check this out

@ask-bonk

ask-bonk Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Nice catch — this is exactly right.

Review on PR #732:

astro:after-swap is dispatched on the document by Astro's view transitions router, not on window. The existing code only restored the sidebar scroll position on initial page load (via the restore() call on line 36) but missed every subsequent client-side navigation because the listener was bound to the wrong target.

What this fixes:
Scroll position is now correctly restored after each astro:after-swap event, which is the whole point of the PR.

Other observations:

  • Good use of transition:persist on SidebarNav — since that DOM element is preserved across swaps, re-setting scrollTop on it after the event fires works perfectly.
  • The sessionStorage read is already wrapped in a safe try/catch, so there's no risk of throwing if storage is unavailable.

Approve. This is a clean, correct one-line fix. 🚢

github run

@mattrothenberg
mattrothenberg merged commit d6abc56 into main Aug 17, 2026
21 of 22 checks passed
@mattrothenberg
mattrothenberg deleted the pmenezes/preserve-docs-nav-scroll branch August 17, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants