From 0668062a073405d7fa47e24aa5764c587141c83c Mon Sep 17 00:00:00 2001 From: James Koster Date: Fri, 20 Nov 2026 16:31:00 +0000 Subject: [PATCH 1/3] 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 --- .../stories/design-system/patterns/settings-page/router.tsx | 6 +++++- .../design-system/patterns/settings-page/style.module.css | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/storybook/stories/design-system/patterns/settings-page/router.tsx b/storybook/stories/design-system/patterns/settings-page/router.tsx index dccf2d4678906f..07dc84e8366450 100644 --- a/storybook/stories/design-system/patterns/settings-page/router.tsx +++ b/storybook/stories/design-system/patterns/settings-page/router.tsx @@ -156,7 +156,11 @@ function useFocusAfterNavigate() { if ( ! container || container.contains( activeElement ) ) { return; } - container.querySelector< HTMLElement >( '[role="region"]' )?.focus(); + // The example sits inside a docs page, so scrolling the region into + // view would move the reader away from where they clicked. + container + .querySelector< HTMLElement >( '[role="region"]' ) + ?.focus( { preventScroll: true } ); }, [ pathname ] ); return containerRef; diff --git a/storybook/stories/design-system/patterns/settings-page/style.module.css b/storybook/stories/design-system/patterns/settings-page/style.module.css index 87fcc7fad638cc..f6b37ed6eb955b 100644 --- a/storybook/stories/design-system/patterns/settings-page/style.module.css +++ b/storybook/stories/design-system/patterns/settings-page/style.module.css @@ -1,10 +1,12 @@ /* * Layout containment makes the frame the containing block for the fixed * overlays portalled into it, and clipping hides a drawer while it slides in. + * A fixed height makes `Page` scroll its own content, as it does in the admin, + * so navigating between pages of different lengths doesn't reflow the docs. */ .example { position: relative; - min-block-size: 640px; + block-size: 720px; display: flex; flex-direction: column; contain: layout; From 945112c26d9da2703ab9049e535804fd4ea6385a Mon Sep 17 00:00:00 2001 From: James Koster Date: Fri, 20 Nov 2026 17:19:42 +0000 Subject: [PATCH 2/3] 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 --- .../stories/design-system/patterns/settings-page/router.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storybook/stories/design-system/patterns/settings-page/router.tsx b/storybook/stories/design-system/patterns/settings-page/router.tsx index 07dc84e8366450..1b261b7ba2b245 100644 --- a/storybook/stories/design-system/patterns/settings-page/router.tsx +++ b/storybook/stories/design-system/patterns/settings-page/router.tsx @@ -195,6 +195,10 @@ function createSettingsRouter( initialPath: string ) { routeTree, history: createBlockingMemoryHistory( initialPath ), defaultNotFoundComponent: () => null, + // The router scrolls the window to the top after each navigation, + // which here is the docs page around the example. Returning false + // skips that, and `Page` keeps its own scroll inside the example. + scrollRestoration: () => false, } ); } From f5f3a94bc3107087ada3feff46ab4895cb01c202 Mon Sep 17 00:00:00 2001 From: James Koster Date: Mon, 23 Nov 2026 09:36:46 +0000 Subject: [PATCH 3/3] 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 --- .../design-system/patterns/settings-page/style.module.css | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/storybook/stories/design-system/patterns/settings-page/style.module.css b/storybook/stories/design-system/patterns/settings-page/style.module.css index f6b37ed6eb955b..db74f3f73e78ce 100644 --- a/storybook/stories/design-system/patterns/settings-page/style.module.css +++ b/storybook/stories/design-system/patterns/settings-page/style.module.css @@ -3,10 +3,12 @@ * overlays portalled into it, and clipping hides a drawer while it slides in. * A fixed height makes `Page` scroll its own content, as it does in the admin, * so navigating between pages of different lengths doesn't reflow the docs. + * Capping it at the viewport height keeps the whole example in view on short + * screens. */ .example { position: relative; - block-size: 720px; + block-size: min(720px, 100dvh); display: flex; flex-direction: column; contain: layout;