Refine PageLayout.Pane resizable persistence API #7417
Draft
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.
Refines the
PageLayout.Paneresizable persistence API with clearer configuration types and simplified custom persistence functions based on design review feedback.Changes
Type Structure
PersistConfiginto three distinct types:NoPersistConfig:{persist: false}- SSR-safe, no width controlLocalStoragePersistConfig:{persist: 'localStorage', widthStorageKey: string, width: number | undefined}- explicit storage key in configCustomPersistConfig:{persist: fn, width: number | undefined}- consumer manages storagewidthis required (can beundefined) for persistence configs to ensure intentional state managementisNoPersistConfig,isLocalStoragePersistConfig,isCustomPersistConfigCustom Persist Functions
(width: number) => void | Promise<void>widthStorageKey- consumers manage their own storage keysSaveOptionstype is now emptyDeprecations
widthStorageKeyprop marked@deprecated- use config object insteadresizable={true}implicitly deprecated - use explicit configMigration Examples
Before (deprecated):
After:
SSR-safe (no persistence):
Changelog
New
NoPersistConfig,LocalStoragePersistConfig,CustomPersistConfigtypesChanged
PersistFunctionsignature: no longer receives options parameterwidthStorageKeymoved intoLocalStoragePersistConfigfrom prop-onlywidthnow required (can beundefined) for persistence configsSaveOptionsis now an empty objectRemoved
SaveOptionsfrom public exports (internal only)Rollout strategy
Minor release with deprecation warnings. Breaking changes deferred to next major version. Backwards compatibility maintained via fallback to
widthStorageKeyprop whenresizable={true}.Testing & Reviewing
resizable={true}testedMerge checklist
Original prompt
Summary
Refine the
PageLayout.Paneresizable persistence API based on design review feedback. This builds on the existing work in themake-primer-react-pagelayout-accept-persisterbranch.API Changes
New Type Definitions
Update the types in
packages/react/src/PageLayout/usePaneWidth.ts:Usage Examples
Deprecation Strategy
Deprecate
widthStorageKeyprop onPageLayout.Pane:@deprecatedJSDoc annotationresizable.widthStorageKey(for localStorage config), falling back to the prop for backwards compatibility withresizable={true}resizable={true}is implicitly deprecated:widthStorageKeyprop (with default fallback){persist: 'localStorage', widthStorageKey: '...', width: undefined}Implementation Changes
Update
usePaneWidth.ts:isLocalStoragePersistConfig,isCustomPersistConfig,isNoPersistConfigsaveWidthto not passwidthStorageKeyto custom persist functionswidthStorageKeyfrom config for localStorage persistresizable === true, fall back towidthStorageKeyfrom hook options (prop)Update
PageLayout.tsx:@deprecatedtowidthStorageKeyprop JSDocwidthStorageKeyprop to hook for backwards compatibilityUpdate
PageLayout/index.ts:NoPersistConfig,LocalStoragePersistConfig,CustomPersistConfigSaveOptionsexport (no longer needed externally)Update
.changeset/pagelayout-resizable-persistence.md:Update
usePaneWidth.test.ts:resizable={true}+widthStorageKeypropUpdate
PageLayout.features.stories.tsx:Rationale
widthrequired for non-false persist: When consumers opt into persistence (localStorage or custom), they should be intentional abo...This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.