An open source design system that's fully customizable and agent ready
TypeScript
fix(ResizeHandle): a grow arrow reopens a collapsed pane (#7512)
Cindy Zhangcbafe4ad4236
diff --git a/.changeset/resize-handle-arrow-reopens.md b/.changeset/resize-handle-arrow-reopens.mdnew file mode 100644index 0000000000..673167888d--- /dev/null+++ b/.changeset/resize-handle-arrow-reopens.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] `ResizeHandle`: on a collapsed pane, the arrow that grows it opens it one step above its minimum, or at its `collapsedSize` when that is larger (a single step below the collapse threshold used to leave it collapsed); the arrow that shrinks it stays a no-op. Enter and double-click still restore the previous size.++@cixzhangdiff --git a/packages/core/src/Resizable/Resizable.spec.md b/packages/core/src/Resizable/Resizable.spec.mdindex 2d34819c2e..7b3363b90b 100644--- a/packages/core/src/Resizable/Resizable.spec.md+++ b/packages/core/src/Resizable/Resizable.spec.md@@ -162,17 +162,18 @@ values used by hook state and painted geometry.reading direction under RTL, with Shift for a larger step, so the pane growsor shrinks by the side of the Handle it sits on; Home moves to the minimumsize and End to the maximum; Enter collapses a collapsible pane and restores- it. An unbounded Handle reports a measured stand-in as `aria-valuemax`: the- window's extent along its axis when no container is supplied, or its- container's content box while a percentage bound observes it, never below its- current size or, while collapsed, its minimum. Implementation gaps under- `spec:AST-020/FR15`: the Handle names the pane it resizes with `aria-controls`- only when its caller passes one (SideNav does); an unbounded Handle in a- container that no percentage bound observes carries no `aria-valuemax`,- because measuring that container would add an observer to a region whose- bounds are all in pixels (Performance and resources); End does not move an- unbounded Handle; and a plain arrow cannot reopen a collapsed pane whose- `collapsedSize` (40 px by default) is larger than one 10 px step.+ it, and the arrow that grows a collapsed pane opens it one step above its+ minimum, or at its `collapsedSize` when that is larger (the shrinking arrow+ leaves it collapsed). An unbounded Handle reports a measured stand-in as+ `aria-valuemax`: the window's extent along its axis when no container is+ supplied, or its container's content box while a percentage bound observes it,+ never below its current size or, while collapsed, its minimum. Implementation+ gaps under `spec:AST-020/FR15`: the Handle names the pane it resizes with+ `aria-controls` only when its caller passes one (SideNav does); an unbounded+ Handle in a container that no percentage bound observes carries no+ `aria-valuemax`, because measuring that container would add an observer to a+ region whose bounds are all in pixels (Performance and resources); and End+ does not move an unbounded Handle.## Design relationships@@ -220,16 +221,16 @@ not emit the documented target state.## Verification map-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |-| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |-| FR1 | `ResizeHandle.test.tsx` plus source inspection | Default, custom, collapsed, disabled, both axes | Handle and Grab zone regressions fail focused tests; custom Grip replacement currently relies on source review. | `audit:Resizable/anatomy` |-| AR1 | `ResizeHandle.test.tsx` ("makes the separator focusable", "exposes the region size and bounds via ARIA", "grows the panel by a step on ArrowRight", "shrinks the panel by a step on ArrowLeft", "uses the large step when Shift is held", "jumps to the minimum on Home", "jumps to the maximum on End", "collapses on Enter when the region is collapsible", "inverts the pointer delta under RTL so dragging resizes intuitively", "restores the previous size, not the minimum, when Enter reopens a collapsed pane", "reopens on Enter even when the minimum size sits below the collapse threshold", "reports the window basis as aria-valuemax when no maximum is configured; End leaves an unbounded region alone", "reports the container basis as aria-valuemax while a percentage bound already observes it", "never reports aria-valuemax below aria-valuemin while collapsed in a small window", "reports no aria-valuemax for an unbounded pixel-only region in a container, which stays unobserved") and `shippedDirections.test.ts`; `SideNav.test.tsx` ("names the nav it resizes with aria-controls (APG window splitter)"); RTL keyboard mirroring, the disabled state, and the collapsed-pane arrow gap under the Window Splitter accessibility contract (`internal/a11y-spec`, pending) | Inline and block axes; LTR and RTL; collapsed; disabled | The Handle loses its role, name, orientation or value properties; an arrow, Home, End or Enter stops moving the divider or moves it against the reading direction | `audit:Resizable/accessibility` |-| FR2 | Source inspection and `themingTargets.test.ts` | Handle, Grip pill, and Grab zone | Removing a target or documenting an unshipped Grab zone target fails evidence or inventory. | `audit:Resizable/theming` |-| FR3 | `ResizeHandle.test.tsx` and `useResizable.test.ts` | Pointer, keyboard, snap, collapse, persistence | Moving resize ownership or changing current transformations fails focused behavior coverage. | `audit:Resizable/behavior` |-| FR4 | Source and public metadata comparison | Horizontal and vertical Handle | No current test detects that documented `direction` is absent from runtime target-state reflection. | `audit:Resizable/theming` |-| FR5 | Hook/utils tests, typecheck, and Chromium | Canonical floor/ceiling/default; invalid XOR shape; SSR/hydration; basis changes; numeric `containerRef` parity | Wrong resolution, rescaling defaults, stale clamps, observer leaks, extra numeric renders/ref reads, or state/paint/storage/ARIA divergence fails. | `audit:Resizable/behavior` |-| FR6 | Hook type/runtime and codemod tests | Removed alias type errors; single/multi-region inline migrations; numeric pixel bounds | A removed alias still type-checks, or migration changes its numeric meaning. | `audit:Resizable/behavior` |-| Theming anatomy map | `scripts/check-knowledge.mjs` | Canonical anatomy and two current targets | Missing, extra, prefixed, stale, or multiply assigned mappings fail repository validation. | `audit:Resizable/theming` |+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |+| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |+| FR1 | `ResizeHandle.test.tsx` plus source inspection | Default, custom, collapsed, disabled, both axes | Handle and Grab zone regressions fail focused tests; custom Grip replacement currently relies on source review. | `audit:Resizable/anatomy` |+| AR1 | `ResizeHandle.test.tsx` ("makes the separator focusable", "exposes the region size and bounds via ARIA", "grows the panel by a step on ArrowRight", "shrinks the panel by a step on ArrowLeft", "uses the large step when Shift is held", "jumps to the minimum on Home", "jumps to the maximum on End", "collapses on Enter when the region is collapsible", "inverts the pointer delta under RTL so dragging resizes intuitively", "restores the previous size, not the minimum, when Enter reopens a collapsed pane", "reopens on Enter even when the minimum size sits below the collapse threshold", "reports the window basis as aria-valuemax when no maximum is configured; End leaves an unbounded region alone", "reports the container basis as aria-valuemax while a percentage bound already observes it", "never reports aria-valuemax below aria-valuemin while collapsed in a small window", "reports no aria-valuemax for an unbounded pixel-only region in a container, which stays unobserved", "a grow arrow opens a collapsed pane one step above its minimum; the shrink arrow leaves it collapsed", "a grow arrow opens a collapsed pane at its collapsedSize when the minimum sits below it", "a grow arrow opens a collapsed pane in the reversed layout and under RTL too", "in a reversed layout, ArrowLeft opens a collapsed pane and ArrowRight leaves it collapsed", "under RTL, ArrowLeft opens a collapsed pane and ArrowRight leaves it collapsed", "a grow arrow opens a hand-built collapsed region one step above its minimum") and `shippedDirections.test.ts`; `SideNav.test.tsx` ("names the nav it resizes with aria-controls (APG window splitter)"); RTL keyboard mirroring, and the disabled state under the Window Splitter accessibility contract (`internal/a11y-spec`, pending) | Inline and block axes; LTR and RTL; collapsed; disabled | The Handle loses its role, name, orientation or value properties; an arrow, Home, End or Enter stops moving the divider or moves it against the reading direction | `audit:Resizable/accessibility` |+| FR2 | Source inspection and `themingTargets.test.ts` | Handle, Grip pill, and Grab zone | Removing a target or documenting an unshipped Grab zone target fails evidence or inventory. | `audit:Resizable/theming` |+| FR3 | `ResizeHandle.test.tsx` and `useResizable.test.ts` | Pointer, keyboard, snap, collapse, persistence | Moving resize ownership or changing current transformations fails focused behavior coverage. | `audit:Resizable/behavior` |+| FR4 | Source and public metadata comparison | Horizontal and vertical Handle | No current test detects that documented `direction` is absent from runtime target-state reflection. | `audit:Resizable/theming` |+| FR5 | Hook/utils tests, typecheck, and Chromium | Canonical floor/ceiling/default; invalid XOR shape; SSR/hydration; basis changes; numeric `containerRef` parity | Wrong resolution, rescaling defaults, stale clamps, observer leaks, extra numeric renders/ref reads, or state/paint/storage/ARIA divergence fails. | `audit:Resizable/behavior` |+| FR6 | Hook type/runtime and codemod tests | Removed alias type errors; single/multi-region inline migrations; numeric pixel bounds | A removed alias still type-checks, or migration changes its numeric meaning. | `audit:Resizable/behavior` |+| Theming anatomy map | `scripts/check-knowledge.mjs` | Canonical anatomy and two current targets | Missing, extra, prefixed, stale, or multiply assigned mappings fail repository validation. | `audit:Resizable/theming` |Current tests exercise Handle and Grab zone structure and behavior but do notrender `children` to prove that custom content replaces Grip pill. That branch is@@ -257,7 +258,7 @@ composition.### The Handle is an APG window splitter-**Decision:** ResizeHandle already acts as one composite control with the splitter's role, value properties, and keyboard, so it adopts the pattern's required parts and its keyboard (AR1), with `aria-controls` the caller does not pass, `aria-valuemax` on an unbounded Handle in a container that no percentage bound observes, End on an unbounded Handle, and the plain-arrow reopen of a collapsed pane recorded as implementation gaps; the inline arrows follow the reading direction because a key that moves the divider against the way it travels on screen is a defect. Decided by `cixzhang`, `2026-10-13`.+**Decision:** ResizeHandle already acts as one composite control with the splitter's role, value properties, and keyboard, so it adopts the pattern's required parts and its keyboard (AR1), with `aria-controls` the caller does not pass, `aria-valuemax` on an unbounded Handle in a container that no percentage bound observes, and End on an unbounded Handle recorded as implementation gaps; the inline arrows follow the reading direction because a key that moves the divider against the way it travels on screen is a defect. Decided by `cixzhang`, `2026-10-13`.**Rejected:** a separate button to collapse the pane; a direction-free ArrowLeft under RTL.diff --git a/packages/core/src/Resizable/ResizeHandle.test.tsx b/packages/core/src/Resizable/ResizeHandle.test.tsxindex 9d9a4e5e5a..eaf33c4ab3 100644--- a/packages/core/src/Resizable/ResizeHandle.test.tsx+++ b/packages/core/src/Resizable/ResizeHandle.test.tsx@@ -452,6 +452,161 @@ describe('ResizeHandle', () => {expect(separator).toHaveAttribute('aria-valuenow', '200');});+ it('a grow arrow opens a collapsed pane one step above its minimum; the shrink arrow leaves it collapsed', () => {+ render(+ <Harness+ config={{+ defaultSize: 200,+ minSize: 100,+ maxSize: 400,+ collapsible: true,+ }}+ />,+ );+ const separator = getSeparator();+ act(() => separator.focus());+ fireEvent.keyDown(separator, {key: 'Enter'});+ expect(separator).toHaveAttribute('aria-valuetext', 'Collapsed');+ // Shrinking a collapsed pane changes nothing.+ fireEvent.keyDown(separator, {key: 'ArrowLeft'});+ expect(separator).toHaveAttribute('aria-valuetext', 'Collapsed');+ // One bare grow step would stay below the collapse threshold (40px) and+ // leave the pane collapsed; instead the arrow opens it one step above the+ // minimum it announced (100 → 110).+ fireEvent.keyDown(separator, {key: 'ArrowRight'});+ expect(separator).not.toHaveAttribute('aria-valuetext');+ expect(separator).toHaveAttribute('aria-valuenow', '110');+ });++ it('a grow arrow opens a collapsed pane at its collapsedSize when the minimum sits below it', () => {+ render(+ <Harness+ config={{+ defaultSize: 200,+ minSize: 20,+ maxSize: 400,+ collapsible: true,+ collapsedSize: 50,+ }}+ />,+ );+ const separator = getSeparator();+ act(() => separator.focus());+ fireEvent.keyDown(separator, {key: 'Enter'});+ expect(separator).toHaveAttribute('aria-valuetext', 'Collapsed');+ // min + step (30) would still be below the 50px threshold, so the pane+ // opens at the threshold instead.+ fireEvent.keyDown(separator, {key: 'ArrowRight'});+ expect(separator).not.toHaveAttribute('aria-valuetext');+ expect(separator).toHaveAttribute('aria-valuenow', '50');+ });++ it('a grow arrow opens a collapsed pane in the reversed layout and under RTL too', () => {+ const rtl = vi+ .spyOn(window, 'getComputedStyle')+ .mockImplementation(+ () => ({direction: 'rtl'}) as unknown as CSSStyleDeclaration,+ );+ try {+ // Reversed + RTL: the pane sits on the right and grows to the left on+ // screen, which under RTL is ArrowRight again.+ render(+ <Harness+ config={{+ defaultSize: 200,+ minSize: 100,+ maxSize: 400,+ collapsible: true,+ }}+ handleProps={{isReversed: true}}+ />,+ );+ const separator = getSeparator();+ act(() => separator.focus());+ fireEvent.keyDown(separator, {key: 'Enter'});+ expect(separator).toHaveAttribute('aria-valuetext', 'Collapsed');+ fireEvent.keyDown(separator, {key: 'ArrowLeft'});+ expect(separator).toHaveAttribute('aria-valuetext', 'Collapsed');+ fireEvent.keyDown(separator, {key: 'ArrowRight'});+ expect(separator).not.toHaveAttribute('aria-valuetext');+ expect(separator).toHaveAttribute('aria-valuenow', '110');+ } finally {+ rtl.mockRestore();+ }+ });++ it('in a reversed layout, ArrowLeft opens a collapsed pane and ArrowRight leaves it collapsed', () => {+ // Reversed: the pane sits on the right and grows to the left.+ render(+ <Harness+ config={{+ defaultSize: 200,+ minSize: 100,+ maxSize: 400,+ collapsible: true,+ }}+ handleProps={{isReversed: true}}+ />,+ );+ const separator = getSeparator();+ act(() => separator.focus());+ fireEvent.keyDown(separator, {key: 'Enter'});+ expect(separator).toHaveAttribute('aria-valuetext', 'Collapsed');+ fireEvent.keyDown(separator, {key: 'ArrowRight'});+ expect(separator).toHaveAttribute('aria-valuetext', 'Collapsed');+ fireEvent.keyDown(separator, {key: 'ArrowLeft'});+ expect(separator).not.toHaveAttribute('aria-valuetext');+ expect(separator).toHaveAttribute('aria-valuenow', '110');+ });++ it('under RTL, ArrowLeft opens a collapsed pane and ArrowRight leaves it collapsed', () => {+ const rtl = vi+ .spyOn(window, 'getComputedStyle')+ .mockImplementation(+ () => ({direction: 'rtl'}) as unknown as CSSStyleDeclaration,+ );+ try {+ // Not reversed, right-to-left: the pane sits on the right and grows+ // toward the left edge of the screen.+ render(+ <Harness+ config={{+ defaultSize: 200,+ minSize: 100,+ maxSize: 400,+ collapsible: true,+ }}+ />,+ );+ const separator = getSeparator();+ act(() => separator.focus());+ fireEvent.keyDown(separator, {key: 'Enter'});+ expect(separator).toHaveAttribute('aria-valuetext', 'Collapsed');+ fireEvent.keyDown(separator, {key: 'ArrowRight'});+ expect(separator).toHaveAttribute('aria-valuetext', 'Collapsed');+ fireEvent.keyDown(separator, {key: 'ArrowLeft'});+ expect(separator).not.toHaveAttribute('aria-valuetext');+ expect(separator).toHaveAttribute('aria-valuenow', '110');+ } finally {+ rtl.mockRestore();+ }+ });++ it('a grow arrow opens a hand-built collapsed region one step above its minimum', () => {+ const props: ResizableProps = {+ ...makeResizable(),+ _isCollapsed: true,+ _size: 0,+ _collapsible: true,+ };+ render(<ResizeHandle resizable={props} label="Resize" />);+ const separator = getSeparator();+ act(() => separator.focus());+ fireEvent.keyDown(separator, {key: 'ArrowRight'});+ // The same move as the hook's own region: minimum plus one step.+ expect(props._onResizeMove).toHaveBeenCalledWith(props._minSizePx + 10);+ });+it('reopens on Enter even when the minimum size sits below the collapse threshold', () => {render(<Harnessdiff --git a/packages/core/src/Resizable/ResizeHandle.tsx b/packages/core/src/Resizable/ResizeHandle.tsxindex 5fcc8cf662..25ae240d3b 100644--- a/packages/core/src/Resizable/ResizeHandle.tsx+++ b/packages/core/src/Resizable/ResizeHandle.tsx@@ -558,20 +558,48 @@ export function ResizeHandle({const step = e.shiftKey ? KEYBOARD_LARGE_STEP : KEYBOARD_STEP;const rtl = isHorizontal ? getRTLMultiplier() : 1;+ // The pane's grow direction on this key: ArrowRight/Down grow unless the+ // layout is reversed or, on the inline axis, right-to-left.+ const grows = (key: string) =>+ (key === 'ArrowRight' || key === 'ArrowDown'+ ? 1+ : key === 'ArrowLeft' || key === 'ArrowUp'+ ? -1+ : 0) *+ (isHorizontal ? rtl : 1) *+ sign >+ 0;+switch (e.key) {case 'ArrowRight':- case 'ArrowDown': {- e.preventDefault();- resizable._onResizeStart();- resizable._onResizeMove(step * (isHorizontal ? rtl : 1) * sign);- resizable._onResizeEnd();- break;- }+ case 'ArrowDown':case 'ArrowLeft':case 'ArrowUp': {e.preventDefault();+ if (resizable._isCollapsed) {+ // A collapsed pane answers only the grow arrow: it opens one step+ // above its minimum, the value the separator announces while+ // collapsed, or at the collapse threshold when that is larger (APG+ // window splitter: the arrow moves the separator from where it is;+ // a bare step would stay below the threshold and leave it in+ // place). The shrink arrow is a no-op.+ if (grows(e.key)) {+ resizable._onResizeStart();+ // At least the collapse threshold, or the move would stay+ // collapsed when the minimum sits below it.+ resizable._onResizeMove(+ Math.max(resizable._minSizePx + step, resizable._collapsedSize),+ );+ resizable._onResizeEnd();+ }+ break;+ }+ const direction =+ e.key === 'ArrowRight' || e.key === 'ArrowDown' ? 1 : -1;resizable._onResizeStart();- resizable._onResizeMove(-step * (isHorizontal ? rtl : 1) * sign);+ resizable._onResizeMove(+ direction * step * (isHorizontal ? rtl : 1) * sign,+ );resizable._onResizeEnd();break;}