fix(core): make Resizable separator keyboard-operable#3729
Open
bhamodi wants to merge 1 commit into
Open
Conversation
|
@bhamodi is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
1d33432 to
31b1576
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Keyboard resizing of
Resizablepanels was dead code. The focusable control is the outerrole="separator"div (ResizeHandle.tsx:aria-valuenow/min/max,tabIndex={isDisabled ? -1 : 0}), butonKeyDown={handleKeyDown}was attached to the inner, absolutely-positioned hit-area child. Keydown events fire on the focused element and bubble up -- they never travel down to a descendant -- so the Arrow / Home / End / Enter handler (handleKeyDown,ResizeHandle.tsx:387-442) never ran for keyboard users. Pointer dragging worked; keyboard operation of the WAI-ARIA window-splitter pattern did not.This moves
onKeyDownonto the focusable separator so the handler actually fires. It is placed after the{...props}spread and composed with any consumer-suppliedonKeyDown(props.onKeyDown?.(e)thenhandleKeyDown(e)). Ordering choice: the sibling handlers (onDoubleClick/onFocus/onBlur) sit before{...props}, so a consumer prop can override them. ForonKeyDownthat would silently re-break keyboard resizing, so this accessibility-critical handler is placed last and composes rather than replaces -- a consumeronKeyDownstill runs, and the resize handler can't be clobbered.The bug shipped because there was no test file for
ResizeHandle/useResizable. This PR adds one.handleKeyDown(unchanged) supports: ArrowRight / ArrowDown grow, ArrowLeft / ArrowUp shrink (step 10, or 50 with Shift), Home jumps tominSizePx, End jumps tomaxSizePx(only when a finite max is set), Enter toggles collapse (only whencollapsible). Horizontal handles are RTL-aware. Keyboard resizing is pure state math inuseResizable(_onResizeStartseeds a ref fromsizestate;_onResizeMoveapplies a delta), so it needs no layout measurement and its observable effect isaria-valuenow.Changes
Resizable/ResizeHandle.tsx: moveonKeyDownfrom the inner hit-area child to the focusablerole="separator"element; place it after{...props}and compose with any consumeronKeyDown. Pointer handlers stay on the hit area.Resizable/ResizeHandle.test.tsx: new file (the gap that let the bug ship).Test plan
node_modules/.bin/vitest run --root . packages/core/src/Resizable-- 11 pass (ResizeHandle.test.tsx). Coverage: ARIA wiring + orientation, separator focusability, ArrowRight/ArrowLeft (± step), Shift = large step, Home → min, End → max, vertical handle ArrowDown/ArrowUp, Enter collapse when collapsible, disabled ignores input (tabIndex -1), and consumeronKeyDownruns alongside resizing (guards the ordering choice).aria-valuenowstays200) while the 3 non-keyboard tests (ARIA wiring, focusable, disabled) pass -- exactly the signature of a handler that never fires. After the fix, all 11 pass.node_modules/.bin/tsc --project packages/core/tsconfig.json --noEmit-- clean.node_modules/.bin/eslinton both changed files -- clean.Notes
Found during an a11y audit of core components; scoped to one fix. It deliberately does not change
role="separator"emission for non-resizable handles (a separate finding), the keyboard steps, or any pointer logic. The file header already documented "keyboard support," which is now actually true.