Export PageLayout resizable functionality#8160
Conversation
🦋 Changeset detectedLatest commit: b07d552 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 |
|
|
🤖 Formatting issues have been automatically fixed and committed to this PR. |
| export const DragHandle = memo<DragHandleProps>(function DragHandle({ | ||
| handleRef, | ||
| onDragStart, | ||
| onDrag, | ||
| onDragEnd, | ||
| onDoubleClick, | ||
| 'aria-valuemin': ariaValueMin, | ||
| 'aria-valuemax': ariaValueMax, | ||
| 'aria-valuenow': ariaValueNow, | ||
| dragTargetRef, | ||
| contentWrapperRef, | ||
| formatValueText = defaultFormatValueText, | ||
| 'data-component': dataComponent = 'PageLayout.DragHandle', | ||
| }) { |
There was a problem hiding this comment.
A near 1:1 with what we already had in PageLayout, just moved to its own file so that it can be exported.
There are a few changes, such as props to improve the portability. Behavior and functionality should remain the same within PageLayout.
| 'aria-valuemin': ariaValueMin, | ||
| 'aria-valuemax': ariaValueMax, | ||
| 'aria-valuenow': ariaValueNow, | ||
| dragTargetRef, |
There was a problem hiding this comment.
This is different compared to how it was in PageLayout. Before we directly used paneRef via context, but now we pass paneRef via this prop in PageLayout.
This is to support usage outside of PageLayout, where the target ref differs from the one within the PageLayout component.
| ) | ||
| }) | ||
|
|
||
| type DragHandleProps = { |
There was a problem hiding this comment.
Drag handler functionality moved to DragHandle.tsx.
There was a problem hiding this comment.
Pull request overview
Exports PageLayout’s resizable-pane building blocks by extracting the drag interaction logic into a standalone DragHandle component and widening usePaneWidth to support usage outside of PageLayout.
Changes:
- Extracted
DragHandleintopackages/react/src/PageLayout/DragHandle.tsxand wired it back intoPageLayout. - Made
usePaneWidth’scontentWrapperRefoptional and added a sharedaria-valuetextformatter hook-up path. - Added new public exports (top-level
@primer/reactandPageLayoutsubpath), plus a dev story demonstrating standalone usage.
Show a summary per file
| File | Description |
|---|---|
| packages/react/src/PageLayout/usePaneWidth.ts | Makes contentWrapperRef optional and centralizes aria-valuetext formatting for DOM updates. |
| packages/react/src/PageLayout/PageLayout.tsx | Replaces inline drag-handle logic with the extracted DragHandle component. |
| packages/react/src/PageLayout/DragHandle.tsx | New standalone component implementing pointer/keyboard resize interactions. |
| packages/react/src/PageLayout/index.ts | Expands PageLayout subpath exports to include resize primitives (and currently also exports paneUtils helpers). |
| packages/react/src/index.ts | Re-exports usePaneWidth, defaultPaneWidth, DragHandle, and related types from PageLayout. |
| packages/react/src/PageLayout/PageLayout.dev.stories.tsx | Adds a dev story demonstrating standalone resizable panel usage. |
| packages/react/src/PageLayout/PageLayout.dev.stories.module.css | Adds styles for the standalone resizable panel dev story. |
| packages/react/src/tests/snapshots/exports.test.ts.snap | Updates export snapshot to reflect newly added top-level exports/types. |
| .changeset/pagelayout-export-resize-primitives.md | Adds a minor changeset for the new public exports. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 2
- Review effort level: Low
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Integration test results from github/github-ui PR:
|
Part of https://github.com/github/core-ux/issues/2973, prerequisite to https://github.com/github/github-ui/pull/26724
Places
PageLayoutdrag functionality into its own component:packages/react/src/PageLayout/DragHandle.tsx, to allow usage outside ofPageLayout.The changes here aim to extend the modularity of
PageLayoutby breaking up the drag functionality. We keep the functionality exactly the same withinPageLayout, but export the pieces that can be used in other components, (see https://github.com/github/core-ux/issues/2973 for more context).PR changes:
packages/react/src/PageLayout/usePaneWidth.tscontentWrapperRefprop optional so that other components can pass or omit a ref.packages/react/src/PageLayout/PageLayout.tsxDragHandleinto its own component (packages/react/src/PageLayout/DragHandle.tsx)DragHandlepackages/react/src/PageLayout/DragHandle.tsxPageLayout.dragTargetRef.Changelog
Changed
DragHandleoutside ofPageLayout.tsx, into its own component.DragHandle/usePaneWidthoutside ofPageLayoutcontext.Rollout strategy
Testing & Reviewing
The behavior should be exactly the same as it is today in production. In addition, I've added a story (on dev) that shows what usage could look like when
DragHandleis used outside ofPageLayout.Questions