An open source design system that's fully customizable and agent ready
TypeScript
fix(SideNav): a resizable rail keeps its nav and items mounted across a collapse (#9290)
Cindy Zhange736b92c8ae7
diff --git a/.changeset/sidenav-collapse-keeps-focus.md b/.changeset/sidenav-collapse-keeps-focus.mdindex c8793971ec..6100689241 100644--- a/.changeset/sidenav-collapse-keeps-focus.md+++ b/.changeset/sidenav-collapse-keeps-focus.md@@ -2,6 +2,6 @@'@astryxdesign/core': patch----[fix] When a collapsible `SideNav` collapses and takes the keyboard focus with it, focus now moves instead of falling to the page, where a keyboard or screen-reader user lost their place (WCAG 2.2 SC 2.4.3). From a row the collapsed rail does not render, such as an item without an icon, focus moves to the collapse toggle, or, with no toggle in the SideNav, to the nearest row still in the rail. On a row the rail keeps, focus stays on that row, and a header or footer control the collapse re-renders under the same name keeps it. From a header or footer control the collapse removes or renames, or the resize handle of a `resizable` SideNav, focus moves to the collapse toggle, or, with none, to the first row. Focus the collapse does not take is not moved.+[fix] When a collapsible `SideNav` collapses and takes the keyboard focus with it, focus now moves instead of falling to the page, where a keyboard or screen-reader user lost their place (WCAG 2.2 SC 2.4.3). From a row the collapsed rail does not render, such as an item without an icon, focus moves to the collapse toggle, or, with no toggle in the SideNav, to the nearest row still in the rail. On a row the rail keeps, focus stays on that row, and a header or footer control the collapse keeps or re-renders under the same name keeps it. From a header or footer control the collapse removes or replaces under another name, or the resize handle of a `resizable` SideNav, focus moves to the collapse toggle, or, with none, to the first row. Focus the collapse does not take is not moved.@cixzhang @duytbpdiff --git a/.changeset/sidenav-resizable-keeps-items-mounted.md b/.changeset/sidenav-resizable-keeps-items-mounted.mdnew file mode 100644index 0000000000..b533bb0d07--- /dev/null+++ b/.changeset/sidenav-resizable-keeps-items-mounted.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] A `resizable` `SideNav` keeps its nav and items mounted when it collapses or expands, as a plain one does. Before, every collapse remounted them, so an open nested group closed and item state reset.++@cixzhang @duytbpdiff --git a/docs/specs/components/SideNav/SideNav.spec.md b/docs/specs/components/SideNav/SideNav.spec.mdindex 8ec777de32..8a1fc41b16 100644--- a/docs/specs/components/SideNav/SideNav.spec.md+++ b/docs/specs/components/SideNav/SideNav.spec.md@@ -113,14 +113,14 @@ Consumer migration instructions belong in consumer docs and release notes.## Behavioral and layout contract-| ID | Invariant | Basis | Draft review state |-| --- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |-| FR1 | SideNav renders its navigation children in a scrollable list, which may be grouped by SideNavSection. A SideNavItem with children renders them, after its own row, in a group labelled by the parent's label; unless `collapsible` is `false`, the group expands and collapses and is hidden from assistive technology and inert while collapsed. | Current source, docs, and tests | Current behavior |-| FR2 | In a collapsed rail, a SideNavItem without an icon is not rendered; a leaf item renders icon-only, named by a non-blank caller `aria-label` or else its label; an item with children renders an icon-only trigger that opens a flyout listing its children as the flyout's top level. | Current source, docs, and tests | Current behavior |-| FR3 | In an expanded rail, in a flyout, and in the mobile navigation drawer, every SideNavItem row MUST span the full inline size of its list at any depth. A row at depth `n` MUST start its content `n` × `--spacing-6` beyond the row's own inline-start padding for its size, inside the row; the nested group MUST add no inset. A flyout's top level is depth 0. | `component:SideNav/DEC-1` | Settled intent; implementation may be staged |-| FR4 | The indent area MUST be part of the row's target: a click there, including a modified or middle click on a link row, does what the same click on the row's primary element does. When the row also carries an independent expand toggle or `actions`, the indent belongs to the primary link or button, and the toggle and actions keep their own activation at the row's trailing edge. | `component:SideNav/DEC-1`; `family:navigation-destinations` | Settled intent; implementation may be staged |-| FR5 | An expanded nested group MUST NOT clip its rows once it has finished opening, so a nested row's focus ring paints in full. The group MAY clip while collapsed and while it opens or closes. | `component:SideNav/DEC-1` | Settled intent; implementation may be staged |-| FR6 | Collapsing or expanding the rail plays one motion on one clock, `spec:AST-105` FR4's one shared motion (`springs.settle`): layout snaps to the final rail width at once, with no width animation, and the rail reveals or covers its labels by a clip, its edge riding the main content's glide and its labels and collapsed icons fading on the same clock (`spec:AST-105` FR9's inline two-state form; the clip and the ride are the shared edge reveal's, and SideNav's own code keeps only the fades; the rail lends no pane to its resize controller, so a collapse plays once; implementation gap: the clip and the ride still run in SideNav's own rail motion code, not in the shared edge reveal): a collapse ends in the real collapsed state, icons only, and an expand ends in the real expanded state, with its labels. On a collapse or an expand the rail's old state is one transient copy, inert and hidden from assistive technology, removed when the motion ends. The main content moves on the same clock, as `component:AppShell` FR17 states. Under reduced motion the rail follows `design:reduced-motion` DR2 under a coarse primary pointer and DR3 otherwise. | `component:SideNav/DEC-2`; `component:AppShell` FR17; `spec:AST-105` FR8, FR9 | Verified by `SideNavRailMotion.test.tsx` and `SideNavRailMotion.interaction.browser.spec.ts`; the `reducedMotion: 'always'` theme case pending |+| ID | Invariant | Basis | Draft review state |+| --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |+| FR1 | SideNav renders its navigation children in a scrollable list, which may be grouped by SideNavSection. A SideNavItem with children renders them, after its own row, in a group labelled by the parent's label; unless `collapsible` is `false`, the group expands and collapses and is hidden from assistive technology and inert while collapsed. | Current source, docs, and tests | Current behavior |+| FR2 | In a collapsed rail, a SideNavItem without an icon is not rendered; a leaf item renders icon-only, named by a non-blank caller `aria-label` or else its label; an item with children renders an icon-only trigger that opens a flyout listing its children as the flyout's top level. | Current source, docs, and tests | Current behavior |+| FR3 | In an expanded rail, in a flyout, and in the mobile navigation drawer, every SideNavItem row MUST span the full inline size of its list at any depth. A row at depth `n` MUST start its content `n` × `--spacing-6` beyond the row's own inline-start padding for its size, inside the row; the nested group MUST add no inset. A flyout's top level is depth 0. | `component:SideNav/DEC-1` | Settled intent; implementation may be staged |+| FR4 | The indent area MUST be part of the row's target: a click there, including a modified or middle click on a link row, does what the same click on the row's primary element does. When the row also carries an independent expand toggle or `actions`, the indent belongs to the primary link or button, and the toggle and actions keep their own activation at the row's trailing edge. | `component:SideNav/DEC-1`; `family:navigation-destinations` | Settled intent; implementation may be staged |+| FR5 | An expanded nested group MUST NOT clip its rows once it has finished opening, so a nested row's focus ring paints in full. The group MAY clip while collapsed and while it opens or closes. | `component:SideNav/DEC-1` | Settled intent; implementation may be staged |+| FR6 | Collapsing or expanding the rail plays one motion on one clock, `spec:AST-105` FR4's one shared motion (`springs.settle`): layout snaps to the final rail width at once, with no width animation, and the rail reveals or covers its labels by a clip, its edge riding the main content's glide and its labels and collapsed icons fading on the same clock (`spec:AST-105` FR9's inline two-state form; the clip and the ride are the shared edge reveal's, and SideNav's own code keeps only the fades; the rail lends no pane to its resize controller, so a collapse plays once; implementation gap: the clip and the ride still run in SideNav's own rail motion code, not in the shared edge reveal): a collapse ends in the real collapsed state, icons only, and an expand ends in the real expanded state, with its labels. On a collapse or an expand the rail's old state is one transient copy, inert and hidden from assistive technology, removed when the motion ends. The main content moves on the same clock, as `component:AppShell` FR17 states. Under reduced motion the rail follows `design:reduced-motion` DR2 under a coarse primary pointer and DR3 otherwise. Collapsing or expanding keeps the nav and its items mounted, a `resizable` rail included, so item state such as an open nested group, and focus, persist (AR3 governs focus on what the collapsed rail does not render). | `component:SideNav/DEC-2`; `component:AppShell` FR17; `spec:AST-105` FR8, FR9 | Verified by `SideNavRailMotion.test.tsx` and `SideNavRailMotion.interaction.browser.spec.ts`; the `reducedMotion: 'always'` theme case pending |### Allowed variation@@ -169,9 +169,9 @@ Consumer migration instructions belong in consumer docs and release notes.rendered inside the SideNav, or, with none, to the nearest row the railkeeps, the preceding one first. A header or footer control the collapsere-renders under the same accessible name keeps focus. From a header or- footer control the collapse removes or renames (a heading link whose- subheading the rail drops), or the resize handle, focus moves to the- collapse toggle, or, with none, to the first row the rail keeps. Focus the collapse does not take is not moved (WCAG 2.2+ footer control the collapse removes or replaces under another name, or the+ resize handle, focus moves to the collapse toggle, or, with none, to the+ first row the rail keeps. Focus the collapse does not take is not moved (WCAG 2.2SC 2.4.3).## Design relationships@@ -208,17 +208,17 @@ Consumer migration instructions belong in consumer docs and release notes.## Verification map-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |-| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ |-| FR1, FR2 | `SideNav.test.tsx` nesting, collapsible, and collapsed-rail suites | Nested, collapsible, collapsed rail, flyout | Removing the labelled group, its collapsed inert state, or the collapsed icon-only and flyout paths fails. | `audit:SideNav/anatomy` |-| FR3, ORD1 | Focused `SideNav.test.tsx` indent coverage, required with implementation | Depth 1 and 2; `sm` and `md`; split and actions rows; caller `style`; flyout | A group inset, a missing or wrong indent, a dropped caller `style`, an indent that overrides a caller-set inline-start padding, or an indented flyout top level fails. | `audit:SideNav/layout` |-| FR3, DD1 | Real-browser geometry over the SideNav nested stories | Depths 1–3; `sm`, `md`, `lg`; light and dark; right-to-left; mobile drawer | A nested row's box narrower than a top-level row's, or a label moved from its per-depth position, fails. | `audit:SideNav/layout` |-| FR4 | Real-browser click in the indent area of plain, split, and actions rows | Link and button rows; plain, modified, and middle clicks; nested rows with toggle and actions | A click in the indent that does nothing or differs from the same click on the primary element, or a toggle or action that activates the row, fails. | `audit:SideNav/behavior` |-| FR5, AR2 | `SideNav.test.tsx` group clipping case and real-browser keyboard focus on nested rows | Only-child and last nested rows; after opening; collapsed | A focus ring cut at any edge of an expanded group, or an expanded group that still clips, fails. | `audit:SideNav/a11y` |-| FR2, FR3 | Real-browser collapsed rail and flyout | Collapsed rail with nested children | Any change to the collapsed rail, or an indent on the flyout's top level, fails. | `audit:SideNav/layout` |-| AR1 | Accessibility-tree comparison of nested rows | Plain, split, and actions rows | Any change in role, name, state, or order fails. | `audit:SideNav/a11y` |-| FR6 | `SideNavRailMotion.test.tsx`; `SideNavRailMotion.interaction.browser.spec.ts` frames of a collapse and an expand under a finger and a mouse (the `reducedMotion: 'always'` theme case pending) | collapse and expand; a mouse and a finger; Reduce Motion under a coarse and under a fine primary pointer; a theme with `reducedMotion: 'always'`; a second toggle while the motion runs | an animated width, a collapse that does not end icons-only, an expand that does not end with its labels, a rail copy reachable by assistive technology or left after the motion ends, travel under Reduce Motion, anything but an opacity-only change of 200 ms or less under Reduce Motion on a coarse pointer (DR2), or any animated property under Reduce Motion on a fine pointer (DR3) fails | `audit:SideNav/behavior` |-| AR3 | `SideNav.test.tsx` collapse-focus suite; `SideNavCollapseFocus.a11y.chromium.spec.ts` | Focus on an icon-less row with and without a toggle, also in a resizable SideNav; a nested row and a kept row's action without a toggle; a kept row's replaced link with a toggle; a footer control, the toggle and Enter on the resize handle in a resizable SideNav; an icon-less heading link the collapse removes; a heading link with a subheading in a resizable SideNav; focus outside the nav; focus on a row the rail keeps; expanding | Focus left on the page body, a move to anything but the kept row's own control, the same header or footer control under the same name, the in-nav toggle, or the nearest kept row (preceding first; the first from a removed header or footer control or the resize handle), or a move of focus the collapse did not take, fails. | `audit:SideNav/a11y` |+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |+| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ |+| FR1, FR2 | `SideNav.test.tsx` nesting, collapsible, and collapsed-rail suites | Nested, collapsible, collapsed rail, flyout | Removing the labelled group, its collapsed inert state, or the collapsed icon-only and flyout paths fails. | `audit:SideNav/anatomy` |+| FR3, ORD1 | Focused `SideNav.test.tsx` indent coverage, required with implementation | Depth 1 and 2; `sm` and `md`; split and actions rows; caller `style`; flyout | A group inset, a missing or wrong indent, a dropped caller `style`, an indent that overrides a caller-set inline-start padding, or an indented flyout top level fails. | `audit:SideNav/layout` |+| FR3, DD1 | Real-browser geometry over the SideNav nested stories | Depths 1–3; `sm`, `md`, `lg`; light and dark; right-to-left; mobile drawer | A nested row's box narrower than a top-level row's, or a label moved from its per-depth position, fails. | `audit:SideNav/layout` |+| FR4 | Real-browser click in the indent area of plain, split, and actions rows | Link and button rows; plain, modified, and middle clicks; nested rows with toggle and actions | A click in the indent that does nothing or differs from the same click on the primary element, or a toggle or action that activates the row, fails. | `audit:SideNav/behavior` |+| FR5, AR2 | `SideNav.test.tsx` group clipping case and real-browser keyboard focus on nested rows | Only-child and last nested rows; after opening; collapsed | A focus ring cut at any edge of an expanded group, or an expanded group that still clips, fails. | `audit:SideNav/a11y` |+| FR2, FR3 | Real-browser collapsed rail and flyout | Collapsed rail with nested children | Any change to the collapsed rail, or an indent on the flyout's top level, fails. | `audit:SideNav/layout` |+| AR1 | Accessibility-tree comparison of nested rows | Plain, split, and actions rows | Any change in role, name, state, or order fails. | `audit:SideNav/a11y` |+| FR6 | `SideNavRailMotion.test.tsx`; `SideNavRailMotion.interaction.browser.spec.ts` frames of a collapse and an expand under a finger and a mouse (the `reducedMotion: 'always'` theme case pending); `SideNav.test.tsx` "keeps its items mounted across a collapse" suite | collapse and expand; a mouse and a finger; Reduce Motion under a coarse and under a fine primary pointer; a theme with `reducedMotion: 'always'`; a second toggle while the motion runs; an open nested group across a collapse and an expand, plain and `resizable` | an animated width, a collapse that does not end icons-only, an expand that does not end with its labels, a rail copy reachable by assistive technology or left after the motion ends, travel under Reduce Motion, anything but an opacity-only change of 200 ms or less under Reduce Motion on a coarse pointer (DR2), or any animated property under Reduce Motion on a fine pointer (DR3) fails A nested group that closes, or item state that resets, across a collapse and an expand fails. | `audit:SideNav/behavior` |+| AR3 | `SideNav.test.tsx` collapse-focus suite; `SideNavCollapseFocus.a11y.chromium.spec.ts`; gap: a rail with no collapse toggle and no row it keeps has no destination, so focus there still falls to the page | Focus on an icon-less row with and without a toggle, also in a resizable SideNav; a nested row and a kept row's action without a toggle; a kept row's replaced link with a toggle; a footer control, the toggle and Enter on the resize handle in a resizable SideNav; an icon-less heading link the collapse removes; a heading link whose subheading the collapsed rail drops, in a resizable SideNav; focus outside the nav; focus on a row the rail keeps; expanding | Focus left on the page body, a move to anything but the kept row's own control, the same header or footer control under the same name, the in-nav toggle, or the nearest kept row (preceding first; the first from a removed header or footer control or the resize handle), or a move of focus the collapse did not take, fails. | `audit:SideNav/a11y` |## Decision logdiff --git a/packages/core/src/SideNav/SideNav.test.tsx b/packages/core/src/SideNav/SideNav.test.tsxindex d298554c70..d99bd08cf5 100644--- a/packages/core/src/SideNav/SideNav.test.tsx+++ b/packages/core/src/SideNav/SideNav.test.tsx@@ -4398,7 +4398,7 @@ describe('SideNav collapse focus (AR3)', () => {expect(screen.getByRole('link', {name: 'Project'})).toHaveFocus();});- it('moves focus to the nearest kept row in a resizable SideNav with no toggle, whose nav remounts as it collapses', () => {+ it('moves focus to the nearest kept row in a resizable SideNav with no toggle', () => {const resizable = (isCollapsed: boolean) => (<SideNavresizable@@ -4517,7 +4517,7 @@ describe('SideNav collapse focus (AR3)', () => {},);- it('moves focus from a heading link the collapse renames (its subheading dropped) to the toggle in a resizable SideNav', () => {+ it('keeps focus on a heading link whose subheading the collapsed rail drops, in a resizable SideNav that keeps its nav mounted (FR6)', () => {const rail = (isCollapsed: boolean) => (<SideNavresizable@@ -4540,7 +4540,8 @@ describe('SideNav collapse focus (AR3)', () => {heading?.focus();expect(heading).toHaveFocus();rerender(rail(true));- expect(screen.getByRole('button', {name: 'Expand sidebar'})).toHaveFocus();+ expect(heading).toHaveFocus();+ expect(heading).toHaveAttribute('aria-label', 'Acme');});it('keeps focus on a heading link the resizable collapse re-renders under the same accessible name, aria-hidden icon text left out', () => {@@ -4564,6 +4565,29 @@ describe('SideNav collapse focus (AR3)', () => {expect(screen.getByRole('link', {name: 'Acme'})).toHaveFocus();});+ it('moves focus to a header control the collapse replaces with a new element under the same accessible name', () => {+ // The app swaps its header button for a new element (a new key) on+ // collapse, under the same name.+ const rail = (isCollapsed: boolean) => (+ <SideNav+ collapsible={{isCollapsed, onCollapsedChange: () => {}}}+ topContent={+ <button key={isCollapsed ? 'compact' : 'full'} type="button">+ Search+ </button>+ }>+ <SideNavItem label="Dashboard" icon={StubIcon} href="/dashboard" />+ </SideNav>+ );+ const {rerender} = render(rail(false));+ const before = screen.getByRole('button', {name: 'Search'});+ before.focus();+ rerender(rail(true));+ const after = screen.getByRole('button', {name: 'Search'});+ expect(after).not.toBe(before);+ expect(after).toHaveFocus();+ });+it('moves no focus when the rail expands', () => {const {rerender} = render(<Rail isCollapsed />);const toggle = screen.getByRole('button', {name: 'Expand sidebar'});@@ -4574,3 +4598,31 @@ describe('SideNav collapse focus (AR3)', () => {).toHaveFocus();});});++describe('SideNav keeps its items mounted across a collapse (FR6)', () => {+ it.each([{resizable: false}, {resizable: true}])(+ 'keeps an open nested group open after a collapse and an expand, resizable $resizable',+ ({resizable}) => {+ const rail = (isCollapsed: boolean) => (+ <SideNav+ resizable={resizable}+ collapsible={{isCollapsed, onCollapsedChange: () => {}}}>+ <SideNavItem+ label="Settings"+ icon={StubIcon}+ collapsible={{defaultIsCollapsed: true}}>+ <SideNavItem label="Billing" href="/settings/billing" />+ </SideNavItem>+ </SideNav>+ );+ const {rerender} = render(rail(false));+ expect(screen.queryByRole('link', {name: 'Billing'})).toBeNull();+ fireEvent.click(screen.getByRole('button', {name: 'Settings'}));+ expect(screen.getByRole('link', {name: 'Billing'})).toBeInTheDocument();+ rerender(rail(true));+ rerender(rail(false));+ // The group the person opened is still open.+ expect(screen.getByRole('link', {name: 'Billing'})).toBeInTheDocument();+ },+ );+});diff --git a/packages/core/src/SideNav/SideNav.tsx b/packages/core/src/SideNav/SideNav.tsxindex 2eccebe216..2b1716226d 100644--- a/packages/core/src/SideNav/SideNav.tsx+++ b/packages/core/src/SideNav/SideNav.tsx@@ -521,7 +521,14 @@ export function SideNav({// it through AppShell's own handle (`component:AppShell` FR17); outside,// SideNav holds its own over its parent.const shell = use(SideNavShellContext);- const ownLayout = useMemo(() => createRailLayout(() => navRef.current), []);+ // A resizable rail's wrapper holds the nav and the handle; outside AppShell+ // it is the rail the motion moves and lays its copy beside (FR6).+ const resizeWrapperRef = useRef<HTMLDivElement>(null);+ const ownRail = useCallback(+ () => resizeWrapperRef.current ?? navRef.current,+ [],+ );+ const ownLayout = useMemo(() => createRailLayout(ownRail), [ownRail]);const railSnapshotRef = useRef<RailSnapshot | null>(null);const motionRef = useRef<{rail: RailMotion; endContent: () => void} | null>(null,@@ -535,7 +542,7 @@ export function SideNav({running?.endContent();motionRef.current = null;railSnapshotRef.current = snapshotRail(- shell?.rail() ?? navRef.current,+ shell?.rail() ?? ownRail(),shell?.animatedLayout ?? ownLayout,shown,wasCollapsed,@@ -550,7 +557,7 @@ export function SideNav({}shell?.beforeRailChange();},- [shell, ownLayout],+ [shell, ownLayout, ownRail],);useLayoutEffect(() => {const snapshot = railSnapshotRef.current;@@ -563,13 +570,13 @@ export function SideNav({motionRef.current = {rail: playRail(snapshot,- shell?.rail() ?? navRef.current,+ shell?.rail() ?? ownRail(),shell?.animatedLayout ?? ownLayout,shell?.column() ?? null,),endContent,};- }, [collapsed, shell, ownLayout]);+ }, [collapsed, shell, ownLayout, ownRail]);// An unmount mid-motion removes the copy at once.useLayoutEffect(() => () => {@@ -586,11 +593,12 @@ export function SideNav({// nested), it moves to the rail's collapse toggle, or, with none, to the// nearest row the rail keeps. Rows and the toggle register through their// callback refs. Rows are matched across the commit by their place among- // the rows the rail keeps, not by element: a resizable SideNav remounts its- // nav when it collapses. Focus on a header or footer control that a- // resizable collapse remounts goes back to the control with the same- // accessible name. From one the collapse removes or renames, or the resize- // handle, focus goes to the toggle, or, with none, to the first kept row.+ // the rows the rail keeps, not by element, since a row's control can be+ // replaced by its collapsed form. Focus on a header or footer control that+ // the collapse replaces goes to the new control with the same accessible+ // name. From one the collapse removes or replaces under another name, or+ // the resize handle, focus goes to the toggle, or, with none, to the first+ // kept row.// Focus moves only if the collapse lost it.const rowsRef = useRef(new Map<HTMLElement, boolean>());const togglesRef = useRef(new Set<HTMLElement>());@@ -611,7 +619,6 @@ export function SideNav({}),[],);- const resizeWrapperRef = useRef<HTMLDivElement>(null);const noteRailFocus = useFocusLeavingChange(collapsed,(wasCollapsed: boolean): PendingRailFocus | null => {@@ -890,26 +897,31 @@ export function SideNav({// Overlay drag handle inside the nav when resizable.// Uses ResizeHandle in overlay mode so the handle sits inside// the panel's overflow: clip bounds.- const rail = showResizeHandle ? (+ // A resizable rail keeps its wrapper while collapsed, so collapsing or+ // expanding never changes the nav's parent: the nav and its items stay+ // mounted, and their state (an open nested group) and focus persist (FR6).+ // Only the handle comes and goes.+ const rail = isResizable ? (<div ref={resizeWrapperRef} {...stylex.props(styles.resizableContainer)}>{navElement}- <ResizeHandle- data-testid="astryx-sidenav-resize-handle"- direction="horizontal"- position="overlay"- pillPlacement="end"- isAlwaysVisible={false}- xstyle={styles.resizableHandle}- resizable={resizableHook.props}- label={t('@astryx.sideNav.resizeSidebar')}- aria-controls={navId}- />+ {showResizeHandle && (+ <ResizeHandle+ data-testid="astryx-sidenav-resize-handle"+ direction="horizontal"+ position="overlay"+ pillPlacement="end"+ isAlwaysVisible={false}+ xstyle={styles.resizableHandle}+ resizable={resizableHook.props}+ label={t('@astryx.sideNav.resizeSidebar')}+ aria-controls={navId}+ />+ )}</div>) : (navElement);- // The snapshot stays mounted outside the resize wrapper, which comes and- // goes with the collapse it measures.+ // The snapshot stays mounted outside the resize wrapper.const content = (<><LayoutChangeSnapshotdiff --git a/packages/core/src/SideNav/SideNavRailMotion.test.tsx b/packages/core/src/SideNav/SideNavRailMotion.test.tsxindex 4be402ba56..8cbdc1bebe 100644--- a/packages/core/src/SideNav/SideNavRailMotion.test.tsx+++ b/packages/core/src/SideNav/SideNavRailMotion.test.tsx@@ -569,14 +569,14 @@ describe('SideNav rail motion (component:SideNav FR6, component:AppShell FR17)',expect(pro).toBeChecked();});- it('plays for a resizable rail too, whose resize wrapper comes and goes with the collapse', async () => {+ it('plays for a resizable rail too, whose resize handle comes and goes with the collapse', async () => {render(<Shell isResizable />);await toggle();expect(railWidth()).toBe(COLLAPSED);expect(animated('clipPath').length).toBeGreaterThan(0);});- it('plays for a resizable rail outside AppShell, whose nav remounts with the collapse', async () => {+ it('plays for a resizable rail outside AppShell, whose resize wrapper is the rail the motion moves', async () => {render(<Shell inShell={false} isResizable />);await toggle();expect(railWidth()).toBe(COLLAPSED);