Repository navigation
feat(SideNav): resizable sidebar with drag handle - #658
Conversation
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsSideNav · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: 1 accessibility violation(s) found — 1 serious. XDSSideNav - 1 issue(s)
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
|
Let's use the same API pattern as collapsible with these props as a Boolean flag or option config like "resizable" |
|
Add this option to the shell lab in sandbox so we can test it. |
1ce6952 to
f67bb33
Compare
Replace isResizable/defaultWidth/onWidthChange with a single resizable
prop matching the collapsible pattern:
- resizable={true} — enable with defaults (260px)
- resizable={{ defaultWidth: 300, onWidthChange }} — configured
- resizable={false} or omit — disabled (default)
Added resizable toggle to shell lab for testing.
Co-authored-by: Navi <[email protected]>
|
Done! Updated in 24e337e — the // Boolean flag
<XDSSideNav resizable>
// Config object
<XDSSideNav resizable={{ defaultWidth: 300, onWidthChange: (w) => save(w) }}>Also added a "Resizable" toggle to the Shell Lab config panel so you can test it in the sandbox preview. |
| // ========================================================================= | ||
| // Resize state — pointer-based drag on the inline-end handle | ||
| // ========================================================================= | ||
| const [width, setWidth] = useState( |
There was a problem hiding this comment.
Can we move all resize feature hooks into a separate useResizeable hook? Then only setup the event listeners if resizeable is enabled.
There was a problem hiding this comment.
Done! Extracted all resize logic into a standalone useResizable hook in useResizable.ts. The hook:
- Encapsulates all resize state (width, refs, hover state)
- Only registers pointer event listeners when
enabledis true - Returns
{ width, containerRef, showHandle, handleProps, isHandleHovered } - XDSSideNav just spreads
handlePropsonto the drag handle element
All 49 existing tests pass with no changes needed.
Move all resize state, pointer event listeners, and drag logic into a standalone useResizable hook. The hook only sets up event listeners when resizable is enabled, and returns handle props + width state. Co-authored-by: Navi <[email protected]>
* feat(SideNav): resizable sidebar with drag handle
* refactor(SideNav): use boolean-or-config pattern for resizable prop
Replace isResizable/defaultWidth/onWidthChange with a single resizable
prop matching the collapsible pattern:
- resizable={true} — enable with defaults (260px)
- resizable={{ defaultWidth: 300, onWidthChange }} — configured
- resizable={false} or omit — disabled (default)
Added resizable toggle to shell lab for testing.
Co-authored-by: Navi <[email protected]>
* refactor(SideNav): extract useResizable hook from XDSSideNav
Move all resize state, pointer event listeners, and drag logic into
a standalone useResizable hook. The hook only sets up event listeners
when resizable is enabled, and returns handle props + width state.
Co-authored-by: Navi <[email protected]>
---------
Co-authored-by: navi[bot] <[email protected]>
* feat(SideNav): resizable sidebar with drag handle
* refactor(SideNav): use boolean-or-config pattern for resizable prop
Replace isResizable/defaultWidth/onWidthChange with a single resizable
prop matching the collapsible pattern:
- resizable={true} — enable with defaults (260px)
- resizable={{ defaultWidth: 300, onWidthChange }} — configured
- resizable={false} or omit — disabled (default)
Added resizable toggle to shell lab for testing.
Co-authored-by: Navi <[email protected]>
* refactor(SideNav): extract useResizable hook from XDSSideNav
Move all resize state, pointer event listeners, and drag logic into
a standalone useResizable hook. The hook only sets up event listeners
when resizable is enabled, and returns handle props + width state.
Co-authored-by: Navi <[email protected]>
---------
Co-authored-by: navi[bot] <[email protected]>
* feat(SideNav): resizable sidebar with drag handle
* refactor(SideNav): use boolean-or-config pattern for resizable prop
Replace isResizable/defaultWidth/onWidthChange with a single resizable
prop matching the collapsible pattern:
- resizable={true} — enable with defaults (260px)
- resizable={{ defaultWidth: 300, onWidthChange }} — configured
- resizable={false} or omit — disabled (default)
Added resizable toggle to shell lab for testing.
* refactor(SideNav): extract useResizable hook from XDSSideNav
Move all resize state, pointer event listeners, and drag logic into
a standalone useResizable hook. The hook only sets up event listeners
when resizable is enabled, and returns handle props + width state.
---------
feat(SideNav): Resizable Sidebar with Drag Handle
Adds a
resizableprop to XDSSideNav using the boolean-or-config pattern (same ascollapsible).API
Behavior
position: absolute)onPointerDown→ documentpointermove→ documentpointerupcol-resizeduring dragrole="separator"witharia-orientation="vertical"Shell Lab
Added "Resizable" toggle to the SideNav config panel.