An open source design system that's fully customizable and agent ready
TypeScript
fix(Toolbar): a link shares the row's single tab stop (#8921)
홍규진b9b2db588ebb
diff --git a/.changeset/toolbar-link-roving.md b/.changeset/toolbar-link-roving.mdnew file mode 100644index 0000000000..2ddd79f896--- /dev/null+++ b/.changeset/toolbar-link-roving.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] A link in a Toolbar (such as a Button with `href`) now shares the toolbar's single tab stop. Arrow keys reach it like any other control, and it no longer adds a second Tab stop to the row.++@kyu-rongdiff --git a/packages/core/src/Toolbar/Toolbar.spec.md b/packages/core/src/Toolbar/Toolbar.spec.mdindex 3b59d07886..b6f6aa8608 100644--- a/packages/core/src/Toolbar/Toolbar.spec.md+++ b/packages/core/src/Toolbar/Toolbar.spec.md@@ -80,10 +80,9 @@ Consumer migration instructions belong in consumer docs and release notes.that does not hold the stop, the stop stays on the earlier control, soShift+Tab from the clicked control lands on that earlier control inside thetoolbar before leaving it.-- **Links and some fields keep their own tab stops.** A link (such as a Button- with `href`), `textarea`, or `select` in the row is outside the roving stop:- it keeps its own tab stop and the arrow keys skip it. The APG toolbar pattern- makes the toolbar a single tab stop.+- **Some fields keep their own tab stops.** A `textarea` or `select` in the+ row is outside the roving stop: it keeps its own tab stop and the arrow keys+ skip it. The APG toolbar pattern makes the toolbar a single tab stop.## Ownership boundary@@ -115,7 +114,7 @@ owns the shared structural-region boundary.| FR1 | The render contains Section-owned Outer chrome around one Toolbar carrying `role="toolbar"`, `aria-label` from `label`, `aria-orientation`, and the `toolbar` target with `size`. Caller `role`, `aria-label`, and `aria-orientation` are dropped; other DOM props reach the toolbar row; `ref`, `className`, `style`, and `xstyle` reach the Section. | Current source, docs, tests, and family || FR2 | Without center content the Toolbar is a flex line of the present start and end lanes, a row when horizontal and a column of lanes when vertical; with center content it is a three-lane grid whose lanes sit side by side in either orientation. Each lane lays its controls out in a row. No lane clips its content, and the center lane can shrink below its content width. `gap` spaces controls within and between lanes. | Current source and focused structure tests || FR3 | Variant (default `transparent`), selected divider edges, and block padding by size remain delegated to Section, while Toolbar retains toolbar semantics, keyboard behavior, and internal layout. | Current source, docs, and family contract |-| FR4 | The row MUST be a single tab stop. ArrowRight and ArrowLeft (horizontal) or ArrowDown and ArrowUp (vertical) move focus between its controls, wrapping at the ends and skipping disabled controls; Home and End move to the first and last. Implementation gap: only buttons, inputs, and elements with `tabindex` share the stop, so links, `textarea`, and `select` keep their own tab stops, and a pointer click does not move the stop (Current-state impact). Arrows do not move focus out of a text input whose caret is mid-line, and inside an open composed menu arrow keys belong to the menu. The toolbar keeps its tab stop after a composed menu is dismissed from outside, and keeps its own arrow movement when rendered inside a popover. | APG toolbar pattern; current source and tests |+| FR4 | The row MUST be a single tab stop. ArrowRight and ArrowLeft (horizontal) or ArrowDown and ArrowUp (vertical) move focus between its controls, wrapping at the ends and skipping disabled controls; Home and End move to the first and last. Implementation gap: only buttons, inputs, links, and elements with `tabindex` share the stop, so `textarea` and `select` carry their own tab stops, and a pointer click does not move the stop (Current-state impact). Arrows do not move focus out of a text input whose caret is mid-line, and inside an open composed menu arrow keys belong to the menu. The toolbar keeps its tab stop after a composed menu is dismissed from outside, and keeps its own arrow movement when rendered inside a popover. | APG toolbar pattern; current source and tests || FR5 | Caller `onKeyDown`, `onFocus`, and `onBlur` run first; when the caller cancels the event, the built-in handling is skipped. | Current source and tests || FR6 | Keyboard focus entering the row can show a brief, self-dismissing hint for its arrow-key axis. | Current source || FR7 | `size` (default `md`) is provided to descendant controls as their default size; Toolbar starts its own size scope and does not inherit an outer size provider (`architecture:component-size-cascade` INV7). | Current source and tests |@@ -204,7 +203,7 @@ Read from source, with no focused test yet:- FR2: the flex and grid layouts themselves, and `gap` spacing.- FR3: divider edges.- FR5: caller `onFocus` and `onBlur` running first and their cancellation.-- FR4: links, `textarea`, and `select` keeping their own tab stops, and the stop+- FR4: `textarea` and `select` keeping their own tab stops, and the stopstaying put after a pointer click.- FR6.- FR7: descendant controls taking `size` as their default, and the fresh sizediff --git a/packages/core/src/Toolbar/Toolbar.test.tsx b/packages/core/src/Toolbar/Toolbar.test.tsxindex ed6a6b7388..16bf9bbd97 100644--- a/packages/core/src/Toolbar/Toolbar.test.tsx+++ b/packages/core/src/Toolbar/Toolbar.test.tsx@@ -370,6 +370,36 @@ describe('Toolbar', () => {expect(buttons[2]).toHaveAttribute('tabindex', '-1');});+ it('keeps a link member in the arrow order and off the tab order', async () => {+ const user = userEvent.setup();+ render(+ <>+ <Toolbar+ label="Actions"+ startContent={+ <>+ <button type="button">Cut</button>+ <a href="https://example.com">Docs</a>+ <button type="button">Paste</button>+ </>+ }+ />+ <button type="button">After</button>+ </>,+ );++ const cut = screen.getByRole('button', {name: 'Cut'});+ cut.focus();+ await user.tab();+ expect(screen.getByRole('button', {name: 'After'})).toHaveFocus();++ cut.focus();+ await user.keyboard('{ArrowRight}');+ expect(screen.getByRole('link', {name: 'Docs'})).toHaveFocus();+ await user.keyboard('{ArrowRight}');+ expect(screen.getByRole('button', {name: 'Paste'})).toHaveFocus();+ });+it('keeps its tab stop after outside dismissal of MoreMenu', async () => {const user = userEvent.setup();render(diff --git a/packages/core/src/Toolbar/Toolbar.tsx b/packages/core/src/Toolbar/Toolbar.tsxindex 9c37d9f3c8..d8dfbe7636 100644--- a/packages/core/src/Toolbar/Toolbar.tsx+++ b/packages/core/src/Toolbar/Toolbar.tsx@@ -248,7 +248,8 @@ export function Toolbar({const gapVar = spacingVars[spacingStepToVar[gap]] as string;const {listRef, handleKeyDown, handleFocus} = useListFocus<HTMLDivElement>({- itemSelector: 'button, input, [tabindex]',+ // `a[href]` catches a Button rendered with `href`.+ itemSelector: 'button, input, a[href], [tabindex]',boundarySelector: '[role="toolbar"], [popover]',orientation,hasRovingTabIndex: true,