Persist sidebar scroll position across navigation#877
Merged
bradygaster merged 2 commits intobradygaster:devfrom Apr 11, 2026
Merged
Conversation
Implements sessionStorage-based persistence for the docs sidebar scroll position, so users retain their scroll state when navigating between articles. Refactors sidebar event binding for idempotency and adds Playwright E2E tests to verify scroll restoration works as intended.
Contributor
🛫 PR Readiness Check
PR Scope: 🔧 Infrastructure
|
| Status | Check | Details |
|---|---|---|
| ❌ | Single commit | 2 commits — consider squashing before review |
| ✅ | Not in draft | Ready for review |
| ✅ | Branch up to date | Up to date with dev |
| ❌ | Copilot review | No Copilot review yet — it may still be processing |
| ✅ | Changeset present | No source files changed — changeset not required |
| ✅ | Scope clean | No .squad/ or docs/proposals/ files |
| ✅ | No merge conflicts | No merge conflicts |
| ✅ | Copilot threads resolved | 1 active Copilot thread(s) resolved (1 outdated skipped) |
| ✅ | CI passing | All checks passing |
Files Changed (2 files, +144 −7)
| File | +/− |
|---|---|
docs/src/components/Sidebar.astro |
+74 −7 |
docs/tests/sidebar.spec.mjs |
+70 −0 |
Total: +144 −7
This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.
Contributor
🟢 Impact Analysis — PR #877Risk tier: 🟢 LOW 📊 Summary
🎯 Risk Factors
📦 Modules Affecteddocs (2 files)
This report is generated automatically for every PR. See #733 for details. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds client-side persistence for the docs sidebar scroll position so users keep their place in the navigation when moving between docs pages, and introduces an E2E test to validate the behavior.
Changes:
- Persist and restore
#sidebarscrollTopviasessionStorage, with idempotent event binding across Astro page swaps. - Update sidebar init behavior to restore saved scroll when available, otherwise scroll the active link into view.
- Add a Playwright E2E test validating sidebar scroll restoration across navigation while main page scroll resets.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| docs/src/components/Sidebar.astro | Implements sessionStorage-based sidebar scroll persistence and swap-safe initialization. |
| docs/tests/sidebar.spec.mjs | Adds Playwright coverage for sidebar scroll restoration across docs navigation. |
Refactored sidebar scroll tracking to use requestAnimationFrame, reducing sessionStorage writes during rapid scrolling. Added flushSidebarScroll to persist the last scroll position on navigation events. Updated event listeners to use the new logic. Improved test stability by switching to expect.poll for scroll restoration checks.
tamirdresher
pushed a commit
that referenced
this pull request
Apr 21, 2026
* Persist sidebar scroll position across navigation Implements sessionStorage-based persistence for the docs sidebar scroll position, so users retain their scroll state when navigating between articles. Refactors sidebar event binding for idempotency and adds Playwright E2E tests to verify scroll restoration works as intended. * Optimize sidebar scroll persistence and test reliability Refactored sidebar scroll tracking to use requestAnimationFrame, reducing sessionStorage writes during rapid scrolling. Added flushSidebarScroll to persist the last scroll position on navigation events. Updated event listeners to use the new logic. Improved test stability by switching to expect.poll for scroll restoration checks. --------- Co-authored-by: Sturla Thorvaldsson <sturla@ibeinni.is>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implements sessionStorage-based persistence for the docs sidebar scroll position, so users retain their scroll state when navigating between articles. Refactors sidebar event binding for idempotency and adds Playwright E2E tests to verify scroll restoration works as intended.
Why
Its very hard to navigate the logs when always being sent to the top of the menu. This way the user can click the next menu item easily.
How
Adds sidebar scroll-state persistence using sessionStorage, saving the current sidebar scrollTop during navigation and restoring it after the next docs page loads. Updates sidebar initialization so event handlers are only registered once across Astro page swaps, preventing duplicate bindings. Falls back to scrolling the active menu item into view only when no saved sidebar position exists. Includes a Playwright test that confirms the article resets to the top while the left navigation keeps its previous scroll position after selecting another docs page.
npx changeset add/.changeset/*.md, directCHANGELOG.mdentry for maintainers, orskip-changeloglabel for no user-facing changes)PR Readiness Checklist
Branch & Commit
dev(notmain)dev(git fetch upstream && git rebase upstream/dev)git diff --cached --stat)Build & Test
npm run buildpassesnpm testpasses (all tests green)! There are currently lot of failing tests locally but not in pipelines..npm run lintpasses (type check clean)npm run lint:eslintpassesChangeset
npx changeset add(ifpackages/squad-sdk/src/orpackages/squad-cli/src/changed)CHANGELOG.mdentry (maintainers only — write-protected for external contributors)skip-changeloglabel applied (if no user-facing changes)Docs
Exports
Breaking Changes
Waivers