feat(PageLayout.Sidebar): support controlled width via currentWidth + onResizeEnd#7900
feat(PageLayout.Sidebar): support controlled width via currentWidth + onResizeEnd#7900mattcosta7 wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: f9a59f7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
There was a problem hiding this comment.
Pull request overview
Adds controlled-width support to PageLayout.Sidebar, aligning it with the existing PageLayout.Pane controlled resize API and flowing through to SplitPageLayout.Sidebar.
Changes:
- Introduces
currentWidth+onResizeEnddiscriminated-union props forPageLayout.Sidebar. - Forwards controlled resize options into
usePaneWidthand adjusts hydration suppression for persistence-only cases. - Adds tests, Storybook examples, docs metadata, and a changeset for the new public API.
Show a summary per file
| File | Description |
|---|---|
packages/react/src/PageLayout/PageLayout.tsx |
Adds Sidebar controlled-width props and forwards them to resize state handling. |
packages/react/src/PageLayout/PageLayout.test.tsx |
Adds component-level coverage for controlled width rendering and resize-end callback behavior. |
packages/react/src/PageLayout/PageLayout.features.stories.tsx |
Adds controlled Sidebar Storybook examples with in-memory and custom persistence. |
packages/react/src/PageLayout/PageLayout.docs.json |
Documents new Sidebar props and related resizable behavior. |
.changeset/pagelayout-sidebar-controlled-width.md |
Adds a minor changeset for the public API addition. |
Copilot's findings
- Files reviewed: 5/5 changed files
- Comments generated: 2
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Closes #
Adds controlled-width support to
PageLayout.Sidebar(and transitivelySplitPageLayout.Sidebar), matching the discriminated-union API that already exists onPageLayout.Pane. The underlyingusePaneWidthhook already accepted these options — this change only exposes them on the Sidebar prop surface and forwards them through.Changelog
New
PageLayout.SidebarandSplitPageLayout.Sidebarnow accept a controlled-width pair:currentWidth: number | undefined— the displayed pane width (in pixels); the existingwidthprop continues to define the default used on reset/double-click.onResizeEnd: (width: number) => void— fires at the end of a drag or keyboard resize gesture; when supplied, localStorage persistence is bypassed entirely (consumer owns persistence).PageLayoutPaneProps— either both are required together or both must be omitted.PageLayout/Features/ResizableSidebarWithoutPersistence— in-memory controlled state, no persistence.PageLayout/Features/ResizableSidebarWithCustomPersistence— controlled state backed by a consumer-managed localStorage key.PageLayout.test.tsx:currentWidthis written into the--pane-widthCSS variable on the sidebar element.onResizeEndis invoked exactly once after a keyboard resize gesture, with a numeric width.PageLayout.docs.json) forcurrentWidth,onResizeEnd, and the previously-undocumentedwidthStorageKeyprop on Sidebar.Changed
PageLayoutSidebarPropsis nowPageLayoutSidebarBaseProps & ({onResizeEnd, currentWidth} | {onResizeEnd?: never, currentWidth?: never})— mirroringPageLayoutPaneProps. The non-controlled shape is unchanged; existing call sites continue to compile.suppressHydrationWarningbecomesresizable === true && !!widthStorageKey && !onResizeEnd— only set when a hydration mismatch is actually possible (server can't read localStorage). Sidebar's opt-in storage model means!!widthStorageKeystays in the predicate (unlike Pane, which defaultswidthStorageKeyto'paneWidth').widthStorageKeyJSDoc now mentions that it is bypassed whenonResizeEndis provided, matching Pane.Removed
Nothing public.
Rollout strategy
(The changeset is published as a minor bump because it adds two new public props on a public component; flag if the team prefers patch.)
Testing & Reviewing
packages/react/src/PageLayout/**andpackages/react/src/SplitPageLayout/**pass (2 pre-existing todos).The new stories are the easiest manual check: drag or arrow-key the divider on
ResizableSidebarWithoutPersistenceand confirm the displayed width in the placeholder label updates on release; reloadResizableSidebarWithCustomPersistenceand confirm the previously-set width is restored from localStorage.Merge checklist