Skip to content

Storybook: Stop Settings Page examples moving the docs page on navigation - #87166

Merged
ciampo merged 3 commits into
trunkfrom
fix/storybook-settings-page-scroll-jumps
Nov 23, 2026
Merged

ciampo merged 3 commits into
trunkfrom
fix/storybook-settings-page-scroll-jumps

Conversation

@jameskoster

Copy link
Copy Markdown
Contributor

What?

Follow up to #86451.

Stops the Settings Page pattern examples from moving the surrounding docs page when you navigate inside them.

Why?

Clicking a navigation item or a subpage row (such as the gateways under "Payment gateways") in the Settings Page examples moved the docs page around the example, so readers lost their place. There were two causes:

  • After a navigation, the example moves focus to the new Page region. focus() also scrolled that region into view, which moved the docs page.
  • The example frame only had a minimum height, so it grew and shrank with each page. Going from Payments to a shorter gateway subpage pulled the content below the example upwards and left the reader at the bottom of the new page.

How?

  • Focus the new page region with { preventScroll: true }. Focus still moves, so screen readers still announce the new page.
  • Give the example frame a fixed block-size: 720px instead of min-block-size: 640px. Page already scrolls its own content with a sticky header, so each example now behaves like an admin screen: the docs page keeps its height, long pages scroll inside the frame, and a new page opens at its top.

Testing Instructions

  1. Run npm run storybook:dev and open Design System → Patterns → Settings Page.
  2. Scroll to "Adjacent pages and subpages" and click "Digital wallets" under "Payment gateways". The docs page shouldn't move, and the subpage should open at its top.
  3. Use the breadcrumbs to go back to Payments, then switch between General, Payments and Emails. The docs page shouldn't move.
  4. Check that long pages scroll inside the example, and that the records examples still open their dialog and drawer inside the frame.

Testing Instructions for Keyboard

  1. Tab to a navigation item or subpage row in an example and press Enter.
  2. Focus should move to the new page region, and the docs page shouldn't scroll.

Use of AI Tools

Claude Code (Claude Opus 5.5) diagnosed the issue, wrote the change, and checked it in the running Storybook. I reviewed the result.

🤖 Generated with Claude Code

…tion

Navigating inside a Settings Page example moved the surrounding docs page in two ways. Focusing the new page region scrolled it into view, and pages of different lengths resized the example, so the reader lost their place.

Focus the region with `preventScroll`, and give the example frame a fixed height so `Page` scrolls its own content, as it does in the admin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jameskoster jameskoster added [Type] Bug An existing feature does not function as intended Storybook Storybook and its stories for components labels Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: 0 B

Total Size: 8.69 MB

f5f3a94 Run

@jameskoster
jameskoster requested a review from a team November 20, 2026 16:32
TanStack Router scrolls the window to the top after each navigation. In the Settings Page examples that window is the docs page, so opening a subpage sent the reader to the top of the docs. Opt out with a `scrollRestoration` function that returns false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On short screens a 720px frame could leave a page's fields above the
viewport, so the example looked blank.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@ciampo ciampo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@ciampo
ciampo merged commit 38617d8 into trunk Nov 23, 2026
68 checks passed
@ciampo
ciampo deleted the fix/storybook-settings-page-scroll-jumps branch November 23, 2026 23:52
@github-actions github-actions Bot added this to the Gutenberg 24.6 milestone Nov 23, 2026
Vedant-Gandhi pushed a commit to Vedant-Gandhi/gutenberg that referenced this pull request Nov 30, 2026
…tion (WordPress#87166)

* Storybook: Stop Settings Page examples moving the docs page on navigation

Navigating inside a Settings Page example moved the surrounding docs page in two ways. Focusing the new page region scrolled it into view, and pages of different lengths resized the example, so the reader lost their place.

Focus the region with `preventScroll`, and give the example frame a fixed height so `Page` scrolls its own content, as it does in the admin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Stop the Settings Page router resetting the docs scroll

TanStack Router scrolls the window to the top after each navigation. In the Settings Page examples that window is the docs page, so opening a subpage sent the reader to the top of the docs. Opt out with a `scrollRestoration` function that returns false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Storybook: Cap the Settings Page example height at the viewport

On short screens a 720px frame could leave a page's fields above the
viewport, so the example looked blank.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Storybook Storybook and its stories for components [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants