Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(Pagination): the dots expose the radio group they already behave as (#8859)

Cindy Zhang40ab0ecf61de
diff --git a/.changeset/pagination-dots-radiogroup.md b/.changeset/pagination-dots-radiogroup.md
new file mode 100644
index 0000000000..fd47da02d6
--- /dev/null
+++ b/.changeset/pagination-dots-radiogroup.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Pagination: the dots variant now exposes the APG radio group it already behaves as. Before, the dots were a `group` of `button`s named "Go to page N", with `aria-current="page"` on the current page. Now the container is a `radiogroup` named by the page-indicators label, and each dot is a `radio` named "Page N" with `aria-checked` on the current page and no `aria-current`. Keyboard behavior is unchanged. A press on a dot now chooses its page on release, so sliding off before release takes the press back.
+
+@cixzhang
diff --git a/apps/storybook/stories/RadioGroupA11y.stories.tsx b/apps/storybook/stories/RadioGroupA11y.stories.tsx
index 9668c4b731..26e98e1e7e 100644
--- a/apps/storybook/stories/RadioGroupA11y.stories.tsx
+++ b/apps/storybook/stories/RadioGroupA11y.stories.tsx
@@ -96,6 +96,10 @@ export const SegmentedOptionGroupDisabledWithMessage = storyFor(
'segmented-option-group-disabled-with-message',
);
+export const PaginationDotsGroup = storyFor('pagination-dots-group');
+export const PaginationDotUnselected = storyFor('pagination-dot-unselected');
+export const PaginationDotSelected = storyFor('pagination-dot-selected');
+
export const MenuGroupSelected = storyFor('menu-group-selected');
export const MenuGroupNoneSelected = storyFor('menu-group-none-selected');
export const MenuOptionUnselectedDescribed = storyFor(
diff --git a/docs/specs/components/Pagination/Pagination.spec.md b/docs/specs/components/Pagination/Pagination.spec.md
index 8812fdf76b..e964bdb8a0 100644
--- a/docs/specs/components/Pagination/Pagination.spec.md
+++ b/docs/specs/components/Pagination/Pagination.spec.md
@@ -13,6 +13,8 @@ review_triggers: [public-api, behavior, layout, theming, accessibility]
verified_by:
[
packages/core/src/Pagination/Pagination.test.tsx,
+ packages/core/src/RadioList/__tests__/RadioGroup.a11y.test.tsx,
+ packages/core/src/RadioList/__tests__/RadioGroup.a11y.chromium.spec.ts,
packages/core/src/hooks/useListFocus.test.tsx,
packages/core/src/theme/themingTargets.test.ts,
scripts/check-knowledge.mjs,
@@ -35,15 +37,15 @@ system_specs:
## Contract at a glance
-| Area | Contract |
-| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
-| Public contract | None changes. Pagination takes `page`, `onChange`, `changeAction`, `totalItems`, `totalPages`, `hasMore`, `pageSize`, `pageSizeOptions`, `onPageSizeChange`, `variant`, `pageLabel`, `hasFirstLast`, `step`, `siblingCount`, `size`, `isDisabled`, `label`, and base props. |
-| Behavior | A labelled navigation landmark with Previous and Next buttons around a variant-specific indicator. Every page change calls `onChange`, announces the new page, and runs an optional `changeAction` with an optimistic page. |
-| End-user impact | People move through pages by buttons, page numbers, dots, or typing a page, and screen-reader users hear the page they landed on. A keyboard user on Next at the last page loses focus because Next becomes natively disabled. |
-| Builder impact | None. |
-| Compatibility/readiness | Records shipped behavior; no API, default, or DOM change. Boundary and disabled buttons use native `disabled`, the dots are not exposed as a radio group and have no coarse-pointer hit area, and delegated Buttons carry their own gaps; all are listed under Current-state impact. |
-| Review checks | Reject a page change outside 1 to the total, a page change without an announcement, a disabled Pagination that changes page, a landmark without a name, or a delegated control re-themed by Pagination. |
-| Governing rules | `spec:AST-020` FR15, DEC-4; `spec:AST-085` FR1, FR4, FR7; `spec:AST-086`; `spec:AST-094` FR42; `spec:AST-102` FR4; `design:bidirectionality` DR6; `design:reduced-motion` DR1; `architecture:component-theming-surface`; `architecture:internationalization` INV1a. |
+| Area | Contract |
+| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Public contract | None changes. Pagination takes `page`, `onChange`, `changeAction`, `totalItems`, `totalPages`, `hasMore`, `pageSize`, `pageSizeOptions`, `onPageSizeChange`, `variant`, `pageLabel`, `hasFirstLast`, `step`, `siblingCount`, `size`, `isDisabled`, `label`, and base props. |
+| Behavior | A labelled navigation landmark with Previous and Next buttons around a variant-specific indicator. Every page change calls `onChange`, announces the new page, and runs an optional `changeAction` with an optimistic page. |
+| End-user impact | People move through pages by buttons, page numbers, dots, or typing a page, and screen-reader users hear the page they landed on. A keyboard user on Next at the last page loses focus because Next becomes natively disabled. |
+| Builder impact | None. |
+| Compatibility/readiness | No API or default change. The dots render as a `radiogroup` of `radio` dots (FR9), a DOM and accessibility-tree change. Boundary and disabled buttons use native `disabled`, the dots have no coarse-pointer hit area, and delegated Buttons carry their own gaps; all are listed under Current-state impact. |
+| Review checks | Reject a page change outside 1 to the total, a page change without an announcement, a disabled Pagination that changes page, a landmark without a name, or a delegated control re-themed by Pagination. |
+| Governing rules | `spec:AST-020` FR15, DEC-4; `spec:AST-085` FR1, FR4, FR7; `spec:AST-086`; `spec:AST-094` FR42; `spec:AST-102` FR4; `design:bidirectionality` DR6; `design:reduced-motion` DR1; `architecture:component-theming-surface`; `architecture:internationalization` INV1a. |
This table is a review projection; the body below is authoritative.
@@ -59,8 +61,10 @@ and its four local theming targets. Consumer usage lives in
- Released default preserved: `yes`; `variant="pages"`, `pageSize={10}`,
`step={1}`, `siblingCount={1}`, `size="md"`
-- Compatibility class: records shipped behavior; no public prop, default,
- export, or DOM change
+- Compatibility class: no public prop, default, or export change; the dots'
+ DOM changes from a `group` of `button`s named "Go to page N" with
+ `aria-current="page"` to a `radiogroup` of `radio` dots named "Page N" with
+ `aria-checked` (FR9)
- Controlled/uncontrolled behavior: controlled; `page` is the committed page,
and Pagination shows an optimistic page only while a `changeAction` is pending
- Migration decision: none
@@ -102,22 +106,22 @@ Consumer migration instructions belong in consumer docs and release notes.
## Behavioral and layout contract
-| ID | Invariant | Basis |
-| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- |
-| FR1 | The current render contains one Pagination landmark (`<nav>` named by `label`, else the localized "Pagination", unless a caller's `aria-labelledby` names it) and Previous/next buttons. Page-size selector, First/last buttons, Page number buttons, Ellipsis, Count readout, Compact readout, Dots, Page input label, Page input, and Page input total appear only when their existing conditions are met. Pagination renders nothing when `totalItems` or the resolved page count is zero or less. | Current source and tests |
-| FR2 | Pagination, Dot, Page input label, and Page input total carry the four current local targets `pagination` (with `data-variant` and `data-size`), `pagination-dot` (`data-active`, `data-size`), `pagination-input-label` (`data-size`), and `pagination-input-total` (`data-size`). | `architecture:component-theming-surface`; current source |
-| FR3 | Page-size selector delegates to Selector; First/last, Previous/next, and Page number buttons delegate to Button; Count and Compact readouts delegate to Text; Page input delegates to NumberInput. The delegated Buttons carry `component:Button`'s gaps: their press scale applies under reduced motion (`design:reduced-motion` DR1) and their height is fixed (`spec:AST-102` FR4). | Current source; `design:reduced-motion` DR1; `spec:AST-102` FR4 |
-| FR4 | Ellipsis is stable visible Pagination-rendered content in a numbered presentation, hidden from assistive technology, and currently carries no public target. | Current source |
-| FR5 | The page count is `totalPages`, else `totalItems / pageSize` rounded up, else unknown. Previous is available above page 1; Next is available below the known count, or when `hasMore` with no count. Previous and Next move by `step`, clamped to 1 and the known count; First goes to 1 and Last to the count. | Current tests |
-| FR6 | Every page change calls `onChange(page)`, announces "Page X of Y" (or "Page X" without a count) through the shared polite channel, and runs `changeAction(page)` in a transition while the optimistic page shows. A later change while one is pending starts a fresh transition. Pagination shows no other pending treatment. | `spec:AST-086`; current tests |
-| FR7 | `pages` shows page buttons for the range when the count is known: every page when the count fits `5 + 2 × siblingCount` slots, otherwise, near an end, `3 + 2 × siblingCount` consecutive pages from that end, an ellipsis, and the other end (page 1 of 10 shows `1 2 3 4 5 … 10`); elsewhere the first page, an ellipsis, the current page with `siblingCount` neighbours, an ellipsis, and the last page. Each page button shows its number, is named "Go to page N", and the current one has `aria-current="page"`. | Current tests |
-| FR8 | `count` shows "X–Y of Z" for the visible item range (needs `totalItems`); `compact` shows "Page X of Y" (needs a count); `none` shows nothing between the buttons. | Current tests |
-| FR9 | With a known count, `dots` renders one dot button per page in a group named by the localized page-indicators label, as one composite single-choice control: a single roving Tab stop on the current dot; ArrowLeft and ArrowRight follow the reading direction (`design:bidirectionality` DR6) and wrap, Home and End reach the first and last dot, and focus landing on a dot selects its page; a click focuses the dot. While disabled, dots stay focusable with `aria-disabled` and change no page. Because the dots already play the APG radio group's role, they MUST expose its required parts: a `radiogroup` container and `radio` dots named by their page with `aria-checked` on the current one (`spec:AST-020` FR15, DEC-4); the arrow keys and Home/End are the composite's adopted extras. Implementation gap: the container is `role="group"` and the dots are buttons with `aria-current` on the current page. Under a coarse pointer each dot MUST gain an invisible hit area, clamped to half the gap between dots (`spec:AST-094` FR42). Implementation gap: dots are 8 px (6 px at `sm`) with no hit area. | `spec:AST-020` FR15, DEC-4; `spec:AST-094` FR42; `design:bidirectionality` DR6; current source and tests |
-| FR10 | `input` renders the page label (visual only), a hidden-label integer NumberInput bounded to 1 and the count, and "/ N" when the count is known. Committing a different page changes to it; the input is disabled without a known count. | `component:NumberInput`; current tests |
-| FR11 | With `pageSizeOptions`, a Selector labelled "Items per page" shows the options; choosing one calls `onPageSizeChange(size)` and then changes to page 1. | Current tests |
-| FR12 | Previous, Next, First, and Last name themselves with localized phrases (Previous and Next name the stride when `step` is above 1) and show that name as a tooltip only while available. Their chevrons mirror under RTL. | `architecture:internationalization`; current source and tests |
-| FR13 | `isDisabled` blocks every page change and disables every control. A disabled or boundary control MUST stay focusable with `aria-disabled` and keep focus when it becomes unavailable (`spec:AST-085` FR1, FR4, FR7). Implementation gap: dots and the page-size Selector use `aria-disabled`, but the Buttons use their native-disabled path, so a focused Previous, Next, First, or Last that reaches a boundary drops focus. | `spec:AST-085`; current source and tests |
-| FR14 | `ref`, `className`, `style`, `xstyle`, `data-testid`, and other base props reach the landmark. A caller's `aria-label` never replaces the computed landmark name (`label`, else the localized default); other caller ARIA props, such as `aria-labelledby`, still reach the landmark. `data-testid` also reaches the input variant's NumberInput as `<id>-input`. | Current tests |
+| ID | Invariant | Basis |
+| ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
+| FR1 | The current render contains one Pagination landmark (`<nav>` named by `label`, else the localized "Pagination", unless a caller's `aria-labelledby` names it) and Previous/next buttons. Page-size selector, First/last buttons, Page number buttons, Ellipsis, Count readout, Compact readout, Dots, Page input label, Page input, and Page input total appear only when their existing conditions are met. Pagination renders nothing when `totalItems` or the resolved page count is zero or less. | Current source and tests |
+| FR2 | Pagination, Dot, Page input label, and Page input total carry the four current local targets `pagination` (with `data-variant` and `data-size`), `pagination-dot` (`data-active`, `data-size`), `pagination-input-label` (`data-size`), and `pagination-input-total` (`data-size`). | `architecture:component-theming-surface`; current source |
+| FR3 | Page-size selector delegates to Selector; First/last, Previous/next, and Page number buttons delegate to Button; Count and Compact readouts delegate to Text; Page input delegates to NumberInput. The delegated Buttons carry `component:Button`'s gaps: their press scale applies under reduced motion (`design:reduced-motion` DR1) and their height is fixed (`spec:AST-102` FR4). | Current source; `design:reduced-motion` DR1; `spec:AST-102` FR4 |
+| FR4 | Ellipsis is stable visible Pagination-rendered content in a numbered presentation, hidden from assistive technology, and currently carries no public target. | Current source |
+| FR5 | The page count is `totalPages`, else `totalItems / pageSize` rounded up, else unknown. Previous is available above page 1; Next is available below the known count, or when `hasMore` with no count. Previous and Next move by `step`, clamped to 1 and the known count; First goes to 1 and Last to the count. | Current tests |
+| FR6 | Every page change calls `onChange(page)`, announces "Page X of Y" (or "Page X" without a count) through the shared polite channel, and runs `changeAction(page)` in a transition while the optimistic page shows. A later change while one is pending starts a fresh transition. Pagination shows no other pending treatment. | `spec:AST-086`; current tests |
+| FR7 | `pages` shows page buttons for the range when the count is known: every page when the count fits `5 + 2 × siblingCount` slots, otherwise, near an end, `3 + 2 × siblingCount` consecutive pages from that end, an ellipsis, and the other end (page 1 of 10 shows `1 2 3 4 5 … 10`); elsewhere the first page, an ellipsis, the current page with `siblingCount` neighbours, an ellipsis, and the last page. Each page button shows its number, is named "Go to page N", and the current one has `aria-current="page"`. | Current tests |
+| FR8 | `count` shows "X–Y of Z" for the visible item range (needs `totalItems`); `compact` shows "Page X of Y" (needs a count); `none` shows nothing between the buttons. | Current tests |
+| FR9 | With a known count, `dots` renders one dot per page in a radio group named by the localized page-indicators label, as one composite single-choice control: a single roving Tab stop on the current dot; ArrowLeft and ArrowRight follow the reading direction (`design:bidirectionality` DR6) and wrap, Home and End reach the first and last dot, and focus landing on a dot selects its page; a press does not focus a dot, and the click on release focuses it, so a press released away selects nothing (WCAG 2.5.2). While disabled, dots stay focusable with `aria-disabled` and change no page. Because the dots already play the APG radio group's role, they MUST expose its required parts: a `radiogroup` container and `radio` dots named by their page with `aria-checked` on the current one (`spec:AST-020` FR15, DEC-4); the arrow keys and Home/End are the composite's adopted extras. Under a coarse pointer each dot MUST gain an invisible hit area, clamped to half the gap between dots (`spec:AST-094` FR42). Implementation gap: dots are 8 px (6 px at `sm`) with no hit area. | `spec:AST-020` FR15, DEC-4; `spec:AST-094` FR42; `design:bidirectionality` DR6; current source and tests |
+| FR10 | `input` renders the page label (visual only), a hidden-label integer NumberInput bounded to 1 and the count, and "/ N" when the count is known. Committing a different page changes to it; the input is disabled without a known count. | `component:NumberInput`; current tests |
+| FR11 | With `pageSizeOptions`, a Selector labelled "Items per page" shows the options; choosing one calls `onPageSizeChange(size)` and then changes to page 1. | Current tests |
+| FR12 | Previous, Next, First, and Last name themselves with localized phrases (Previous and Next name the stride when `step` is above 1) and show that name as a tooltip only while available. Their chevrons mirror under RTL. | `architecture:internationalization`; current source and tests |
+| FR13 | `isDisabled` blocks every page change and disables every control. A disabled or boundary control MUST stay focusable with `aria-disabled` and keep focus when it becomes unavailable (`spec:AST-085` FR1, FR4, FR7). Implementation gap: dots and the page-size Selector use `aria-disabled`, but the Buttons use their native-disabled path, so a focused Previous, Next, First, or Last that reaches a boundary drops focus. | `spec:AST-085`; current source and tests |
+| FR14 | `ref`, `className`, `style`, `xstyle`, `data-testid`, and other base props reach the landmark. A caller's `aria-label` never replaces the computed landmark name (`label`, else the localized default); other caller ARIA props, such as `aria-labelledby`, still reach the landmark. `data-testid` also reaches the input variant's NumberInput as `<id>-input`. | Current tests |
### Allowed variation
@@ -130,15 +134,15 @@ Consumer migration instructions belong in consumer docs and release notes.
### Representative states
-| State | Required invariant | Allowed variation |
-| -------------------- | ---------------------------------------------------------------------------------------------------------- | ----------------- |
-| First page | Previous unavailable; Next available. | Variant. |
-| Middle page, `pages` | Range with ellipses; current page `aria-current`. | `siblingCount`. |
-| Cursor paging | No count; Next follows `hasMore`; count-only indicators hidden. | — |
-| Input variant | Label, bounded input, total; First and Last by default. | `pageLabel`. |
-| Disabled | No page change from any control. Implementation gap: native `disabled` on Buttons (FR13). | — |
-| Dots | One Tab stop; arrows, Home, and End select. Implementation gap: group of buttons, not a radio group (FR9). | Size. |
-| Zero items | Nothing renders. | — |
+| State | Required invariant | Allowed variation |
+| -------------------- | ----------------------------------------------------------------------------------------- | ----------------- |
+| First page | Previous unavailable; Next available. | Variant. |
+| Middle page, `pages` | Range with ellipses; current page `aria-current`. | `siblingCount`. |
+| Cursor paging | No count; Next follows `hasMore`; count-only indicators hidden. | — |
+| Input variant | Label, bounded input, total; First and Last by default. | `pageLabel`. |
+| Disabled | No page change from any control. Implementation gap: native `disabled` on Buttons (FR13). | — |
+| Dots | One Tab stop; arrows, Home, and End select. A radio group of page radios (FR9). | Size. |
+| Zero items | Nothing renders. | — |
### Transformation and precedence order
@@ -161,8 +165,8 @@ Consumer migration instructions belong in consumer docs and release notes.
- **AR1 — Landmark.** A named `nav` landmark (FR1).
- **AR2 — Current page.** `aria-current="page"` on the current page button
- (FR7). The dots MUST expose the current page with `aria-checked` in a radio
- group; FR9 records the gap.
+ (FR7). The dots expose the current page with `aria-checked` in a radio
+ group (FR9).
- **AR3 — Announcement.** FR6.
- **AR4 — Disabled and boundaries.** FR13.
- **AR5 — Decorative parts.** The ellipsis and the input variant's page label
@@ -240,34 +244,31 @@ does not decide whether it should remain unreachable.
- Button, Text, NumberInput, and Selector retain ownership of their delegated
targets and presentation.
- `spec:AST-085` owns disabled focusability; FR13 records the gap.
-- `spec:AST-020` FR15 owns which APG parts the dots adopt; FR9 records the gap.
+- `spec:AST-020` FR15 owns which APG parts the dots adopt (FR9).
- `spec:AST-094` FR42 owns coarse-pointer hit areas; FR9 records the gap.
- `spec:AST-086` owns the page announcement channel.
## Verification map
-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
-| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
-| FR1, FR14 | `Pagination.test.tsx` basic-rendering, zero-item, and rest-forwarding cases | Default and custom label; zero items or pages; `data-testid`, `id`, `aria-describedby` | A missing or misnamed landmark, a render at zero, or a dropped `data-testid`, `id`, or `aria-*` fails. Evidence gap: no test asserts `ref`, `className`, `style`, `xstyle`, the computed `aria-label` replacing a caller's, a caller's `aria-labelledby` reaching the landmark, or the input variant's `<id>-input` test id. | `audit:Pagination/anatomy` |
-| FR2 | `themingTargets.test.ts` | Rendered targets | A rendered class absent from the documented targets fails. Evidence gap: no test asserts the placement or reflected properties of the four local targets (OQ1). | `audit:Pagination/theming` |
-| FR3 | `Pagination.test.tsx` "does not introduce Stack theme targets around navigation controls" | Navigation controls | An added Stack target fails. Evidence gap: no test asserts each delegated owner; the delegated Button gaps are asserted by `component:Button`'s own records, not here. | `audit:Pagination/theming` |
-| FR4, FR7 | `generatePageRange` cases; `Pagination.test.tsx` pages cases ("renders page number buttons", "marks current page with aria-current", "shows ellipsis for many pages") | Left, right, and two-sided omission; `siblingCount` 0 and 2 | A wrong range, a missing ellipsis, or a missing `aria-current` fails. Evidence gap: no test asserts that the ellipsis is hidden from assistive technology. | `audit:Pagination/behavior` |
-| FR5, ORD1 | `Pagination.test.tsx` boundary, cursor, step, page-size guarding, and totalItems cases | First, middle, last, single page; `hasMore`; step clamp; invalid `pageSize` | A move past a bound or a wrong count derived from `totalItems` and `pageSize` fails. Evidence gap: no test passes both `totalItems` and `totalPages`, so ORD1's precedence is untested. | `audit:Pagination/behavior` |
-| FR6, ORD2 | `Pagination.test.tsx` page-change and changeAction cases | Mount, page button, Previous, Next, dot; pending, interrupted, and synchronous Actions; disabled | A missing `onChange`, announcement, or optimistic page, a `changeAction` before `onChange`, or an Action while disabled fails. Evidence gap: no test asserts the announcement's order relative to `onChange`. | `audit:Pagination/behavior` |
-| FR8 | `Pagination.test.tsx` count and compact cases | Count range and last-page clamp; compact text | A wrong readout fails. | `audit:Pagination/behavior` |
-| FR9 | `Pagination.test.tsx` dots cases ("uses roving tabindex — active dot has tabIndex 0, others -1", "ArrowRight moves focus to the next dot and selects it", "Home selects the first page, End the last", the wrap cases, "does not navigate with arrow keys when disabled", "marks active dot with aria-current" asserting the current gap pending conformance); `useListFocus.test.tsx` RTL cases | Dots; RTL; disabled | A second Tab stop, an arrow or Home/End that does not select, a missing wrap, a disabled dot that drops focus or changes page, or reversed RTL arrows fail. Evidence gap: no Pagination-level RTL dots test and no coarse-pointer hit-area test. | `audit:Pagination/accessibility` |
-| FR10 | `Pagination.test.tsx` input and pageLabel cases | Known and unknown totals; Enter, blur, invalid, below and above range; custom label; disabled | A wrong bound, a missing commit or announcement, or a commit while disabled fails. | `audit:Pagination/behavior` |
-| FR11 | `Pagination.test.tsx` page-size selector cases | With and without `pageSizeOptions` | Evidence gap: the page-size cases only check that the landmark and buttons render, so no test asserts the Selector's presence or absence, `onPageSizeChange`, or the reset to page 1. | `audit:Pagination/behavior` |
-| FR12, ORD3 | `Pagination.test.tsx` first/last, step-name, tooltip, and RTL chevron cases | `hasFirstLast` on `compact` and `input`; stride names; RTL | A wrong name, a missing First or Last, a Previous or Next without a tooltip, or a First or Last chevron that does not mirror like Previous and Next fails. Evidence gap: no test asserts the tooltip text, that the tooltip is absent while a control is unavailable, or that the chevrons mirror under RTL. | `audit:Pagination/accessibility` |
-| FR13 | `Pagination.test.tsx` disabled-state and boundary cases, asserting native `disabled` on the Buttons as the current gap pending conformance | Disabled; first and last page | A page change while disabled fails. Evidence gap: no test asserts focus kept at a boundary. | `audit:Pagination/accessibility` |
-| PR1, AR1–AR5 | PR1 has no test (evidence gap). AR1 to AR5 are covered by the FR1, FR6, FR7, FR9, FR10, and FR13 rows. | — | — | `audit:Pagination/accessibility` |
-| Theming anatomy map | `scripts/check-knowledge.mjs` | Canonical anatomy and current targets | Missing, extra, or stale mappings fail repository validation. | `audit:Pagination/theming` |
+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
+| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
+| FR1, FR14 | `Pagination.test.tsx` basic-rendering, zero-item, and rest-forwarding cases | Default and custom label; zero items or pages; `data-testid`, `id`, `aria-describedby` | A missing or misnamed landmark, a render at zero, or a dropped `data-testid`, `id`, or `aria-*` fails. Evidence gap: no test asserts `ref`, `className`, `style`, `xstyle`, the computed `aria-label` replacing a caller's, a caller's `aria-labelledby` reaching the landmark, or the input variant's `<id>-input` test id. | `audit:Pagination/anatomy` |
+| FR2 | `themingTargets.test.ts` | Rendered targets | A rendered class absent from the documented targets fails. Evidence gap: no test asserts the placement or reflected properties of the four local targets (OQ1). | `audit:Pagination/theming` |
+| FR3 | `Pagination.test.tsx` "does not introduce Stack theme targets around navigation controls" | Navigation controls | An added Stack target fails. Evidence gap: no test asserts each delegated owner; the delegated Button gaps are asserted by `component:Button`'s own records, not here. | `audit:Pagination/theming` |
+| FR4, FR7 | `generatePageRange` cases; `Pagination.test.tsx` pages cases ("renders page number buttons", "marks current page with aria-current", "shows ellipsis for many pages") | Left, right, and two-sided omission; `siblingCount` 0 and 2 | A wrong range, a missing ellipsis, or a missing `aria-current` fails. Evidence gap: no test asserts that the ellipsis is hidden from assistive technology. | `audit:Pagination/behavior` |
+| FR5, ORD1 | `Pagination.test.tsx` boundary, cursor, step, page-size guarding, and totalItems cases | First, middle, last, single page; `hasMore`; step clamp; invalid `pageSize` | A move past a bound or a wrong count derived from `totalItems` and `pageSize` fails. Evidence gap: no test passes both `totalItems` and `totalPages`, so ORD1's precedence is untested. | `audit:Pagination/behavior` |
+| FR6, ORD2 | `Pagination.test.tsx` page-change and changeAction cases | Mount, page button, Previous, Next, dot; pending, interrupted, and synchronous Actions; disabled | A missing `onChange`, announcement, or optimistic page, a `changeAction` before `onChange`, or an Action while disabled fails. Evidence gap: no test asserts the announcement's order relative to `onChange`. | `audit:Pagination/behavior` |
+| FR8 | `Pagination.test.tsx` count and compact cases | Count range and last-page clamp; compact text | A wrong readout fails. | `audit:Pagination/behavior` |
+| FR9 | `Pagination.test.tsx` dots cases ("uses roving tabindex — active dot has tabIndex 0, others -1", "ArrowRight moves focus to the next dot and selects it", "Home selects the first page, End the last", the wrap cases, "does not navigate with arrow keys when disabled", the radio-group parts through `RadioGroup.a11y.test.tsx` and `RadioGroup.a11y.chromium.spec.ts` (Pagination dots states)); `useListFocus.test.tsx` RTL cases | Dots; RTL; disabled | A second Tab stop, an arrow or Home/End that does not select, a missing wrap, a disabled dot that drops focus or changes page, or reversed RTL arrows fail. Evidence gap: no Pagination-level RTL dots test and no coarse-pointer hit-area test. | `audit:Pagination/accessibility` |
+| FR10 | `Pagination.test.tsx` input and pageLabel cases | Known and unknown totals; Enter, blur, invalid, below and above range; custom label; disabled | A wrong bound, a missing commit or announcement, or a commit while disabled fails. | `audit:Pagination/behavior` |
+| FR11 | `Pagination.test.tsx` page-size selector cases | With and without `pageSizeOptions` | Evidence gap: the page-size cases only check that the landmark and buttons render, so no test asserts the Selector's presence or absence, `onPageSizeChange`, or the reset to page 1. | `audit:Pagination/behavior` |
+| FR12, ORD3 | `Pagination.test.tsx` first/last, step-name, tooltip, and RTL chevron cases | `hasFirstLast` on `compact` and `input`; stride names; RTL | A wrong name, a missing First or Last, a Previous or Next without a tooltip, or a First or Last chevron that does not mirror like Previous and Next fails. Evidence gap: no test asserts the tooltip text, that the tooltip is absent while a control is unavailable, or that the chevrons mirror under RTL. | `audit:Pagination/accessibility` |
+| FR13 | `Pagination.test.tsx` disabled-state and boundary cases, asserting native `disabled` on the Buttons as the current gap pending conformance | Disabled; first and last page | A page change while disabled fails. Evidence gap: no test asserts focus kept at a boundary. | `audit:Pagination/accessibility` |
+| PR1, AR1–AR5 | PR1 has no test (evidence gap). AR1 to AR5 are covered by the FR1, FR6, FR7, FR9, FR10, and FR13 rows. | — | — | `audit:Pagination/accessibility` |
+| Theming anatomy map | `scripts/check-knowledge.mjs` | Canonical anatomy and current targets | Missing, extra, or stale mappings fail repository validation. | `audit:Pagination/theming` |
## Current-state impact
-- **Dots semantics (FR9).** The dots act as one single-choice control but are
- exposed as a group of buttons with `aria-current`, not a radio group, against
- `spec:AST-020` FR15.
- **Dot hit area (FR9).** Dots are 8 px (6 px at `sm`) with no coarse-pointer
hit area, against `spec:AST-094` FR42.
- **Open variant axis (AV2).** The variant map accepts module-augmented
diff --git a/packages/core/src/Pagination/Pagination.test.tsx b/packages/core/src/Pagination/Pagination.test.tsx
index 7459deebb7..08e9422ee9 100644
--- a/packages/core/src/Pagination/Pagination.test.tsx
+++ b/packages/core/src/Pagination/Pagination.test.tsx
@@ -548,8 +548,8 @@ describe('Pagination', () => {
variant="dots"
/>,
);
- const group = screen.getByRole('group', {name: 'Page indicators'});
- expect(within(group).getAllByRole('button')).toHaveLength(5);
+ const group = screen.getByRole('radiogroup', {name: 'Page indicators'});
+ expect(within(group).getAllByRole('radio')).toHaveLength(5);
});
it('treats NaN pageSize as the default', () => {
@@ -606,29 +606,31 @@ describe('Pagination', () => {
variant="dots"
/>,
);
- const group = screen.getByRole('group', {name: 'Page indicators'});
- const dots = within(group).getAllByRole('button');
+ const group = screen.getByRole('radiogroup', {name: 'Page indicators'});
+ const dots = within(group).getAllByRole('radio');
expect(dots).toHaveLength(5);
});
- it('marks active dot with aria-current', () => {
+ // -------------------------------------------------------------------------
+ // Keyboard navigation (roving tabindex + arrow keys via useListFocus).
+ // Selection follows focus: arrow/Home/End move focus and select that page.
+ // -------------------------------------------------------------------------
+
+ it('does not choose a page on the press: the browser keeps focus off the dot until the click', () => {
+ const onChange = vi.fn();
render(
<Pagination
- page={3}
- onChange={() => {}}
- totalPages={5}
+ page={1}
+ onChange={onChange}
+ totalPages={3}
variant="dots"
/>,
);
- const activeDot = screen.getByRole('button', {name: 'Go to page 3'});
- expect(activeDot).toHaveAttribute('aria-current', 'page');
+ const dot = screen.getByRole('radio', {name: 'Page 2'});
+ expect(fireEvent.mouseDown(dot)).toBe(false);
+ expect(onChange).not.toHaveBeenCalled();
});
- // -------------------------------------------------------------------------
- // Keyboard navigation (roving tabindex + arrow keys via useListFocus).
- // Selection follows focus: arrow/Home/End move focus and select that page.
- // -------------------------------------------------------------------------
-
it('uses roving tabindex — active dot has tabIndex 0, others -1', () => {
render(
<Pagination
@@ -638,15 +640,18 @@ describe('Pagination', () => {
variant="dots"
/>,
);
- expect(
- screen.getByRole('button', {name: 'Go to page 2'}),
- ).toHaveAttribute('tabindex', '0');
- expect(
- screen.getByRole('button', {name: 'Go to page 1'}),
- ).toHaveAttribute('tabindex', '-1');
- expect(
- screen.getByRole('button', {name: 'Go to page 3'}),
- ).toHaveAttribute('tabindex', '-1');
+ expect(screen.getByRole('radio', {name: 'Page 2'})).toHaveAttribute(
+ 'tabindex',
+ '0',
+ );
+ expect(screen.getByRole('radio', {name: 'Page 1'})).toHaveAttribute(
+ 'tabindex',
+ '-1',
+ );
+ expect(screen.getByRole('radio', {name: 'Page 3'})).toHaveAttribute(
+ 'tabindex',
+ '-1',
+ );
});
it('ArrowRight moves focus to the next dot and selects it', async () => {
@@ -660,10 +665,10 @@ describe('Pagination', () => {
variant="dots"
/>,
);
- screen.getByRole('button', {name: 'Go to page 2'}).focus();
+ screen.getByRole('radio', {name: 'Page 2'}).focus();
await user.keyboard('{ArrowRight}');
expect(onChange).toHaveBeenCalledWith(3);
- expect(screen.getByRole('button', {name: 'Go to page 3'})).toHaveFocus();
+ expect(screen.getByRole('radio', {name: 'Page 3'})).toHaveFocus();
});
it('ArrowLeft moves focus to the previous dot and selects it', async () => {
@@ -677,10 +682,10 @@ describe('Pagination', () => {
variant="dots"
/>,
);
- screen.getByRole('button', {name: 'Go to page 3'}).focus();
+ screen.getByRole('radio', {name: 'Page 3'}).focus();
await user.keyboard('{ArrowLeft}');
expect(onChange).toHaveBeenCalledWith(2);
- expect(screen.getByRole('button', {name: 'Go to page 2'})).toHaveFocus();
+ expect(screen.getByRole('radio', {name: 'Page 2'})).toHaveFocus();
});
it('Home selects the first page, End the last', async () => {
@@ -694,10 +699,10 @@ describe('Pagination', () => {
variant="dots"
/>,
);
- screen.getByRole('button', {name: 'Go to page 3'}).focus();
+ screen.getByRole('radio', {name: 'Page 3'}).focus();
await user.keyboard('{Home}');
expect(onChange).toHaveBeenCalledWith(1);
- expect(screen.getByRole('button', {name: 'Go to page 1'})).toHaveFocus();
+ expect(screen.getByRole('radio', {name: 'Page 1'})).toHaveFocus();
onChange.mockClear();
rerender(
@@ -708,10 +713,10 @@ describe('Pagination', () => {
variant="dots"
/>,
);
- screen.getByRole('button', {name: 'Go to page 3'}).focus();
+ screen.getByRole('radio', {name: 'Page 3'}).focus();
await user.keyboard('{End}');
expect(onChange).toHaveBeenCalledWith(5);
- expect(screen.getByRole('button', {name: 'Go to page 5'})).toHaveFocus();
+ expect(screen.getByRole('radio', {name: 'Page 5'})).toHaveFocus();
});
it('wraps from the last dot to the first with ArrowRight', async () => {
@@ -725,10 +730,10 @@ describe('Pagination', () => {
variant="dots"
/>,
);
- screen.getByRole('button', {name: 'Go to page 4'}).focus();
+ screen.getByRole('radio', {name: 'Page 4'}).focus();
await user.keyboard('{ArrowRight}');
expect(onChange).toHaveBeenCalledWith(1);
- expect(screen.getByRole('button', {name: 'Go to page 1'})).toHaveFocus();
+ expect(screen.getByRole('radio', {name: 'Page 1'})).toHaveFocus();
});
it('wraps from the first dot to the last with ArrowLeft', async () => {
@@ -742,10 +747,10 @@ describe('Pagination', () => {
variant="dots"
/>,
);
- screen.getByRole('button', {name: 'Go to page 1'}).focus();
+ screen.getByRole('radio', {name: 'Page 1'}).focus();
await user.keyboard('{ArrowLeft}');
expect(onChange).toHaveBeenCalledWith(4);
- expect(screen.getByRole('button', {name: 'Go to page 4'})).toHaveFocus();
+ expect(screen.getByRole('radio', {name: 'Page 4'})).toHaveFocus();
});
it('does not navigate with arrow keys when disabled', async () => {
@@ -760,7 +765,7 @@ describe('Pagination', () => {
isDisabled
/>,
);
- const dot = screen.getByRole('button', {name: 'Go to page 2'});
+ const dot = screen.getByRole('radio', {name: 'Page 2'});
// spec:AST-085 FR1: the active dot keeps its tab stop, exposed as disabled.
expect(dot).not.toHaveAttribute('disabled');
expect(dot).toHaveAttribute('aria-disabled', 'true');
@@ -1313,7 +1318,7 @@ describe('Pagination', () => {
variant="dots"
/>,
);
- await user.click(screen.getByRole('button', {name: 'Go to page 4'}));
+ await user.click(screen.getByRole('radio', {name: 'Page 4'}));
expect(onChange).toHaveBeenCalledWith(4);
});
});
diff --git a/packages/core/src/Pagination/Pagination.tsx b/packages/core/src/Pagination/Pagination.tsx
index 67b93acb08..71ce155470 100644
--- a/packages/core/src/Pagination/Pagination.tsx
+++ b/packages/core/src/Pagination/Pagination.tsx
@@ -41,6 +41,9 @@ import {Selector} from '../Selector';
import {Text} from '../Text';
import {useAnnounce} from '../hooks/useAnnounce';
import {useListFocus} from '../hooks/useListFocus';
+import {useMergedRefs} from '../hooks/useMergedRefs';
+import {focusForLastInput} from '../utils/focusReturn';
+import {useInteractionModalityTracking} from '../utils/interactionModality';
import {mergeProps, rtlStyles} from '../utils';
import type {BaseProps} from '../BaseProps';
import {themeProps} from '../utils/themeProps';
@@ -460,6 +463,9 @@ export function Pagination({
wrap: true,
orientation: 'horizontal',
});
+ // The click's focus takes the ring of the dots' own document's last input.
+ const {ref: modalityRef} = useInteractionModalityTracking();
+ const dotsRef = useMergedRefs(dotsListRef, modalityRef);
const computedTotalPages =
totalPagesProp ??
@@ -688,9 +694,12 @@ export function Pagination({
return (
<div
- ref={dotsListRef}
+ ref={dotsRef}
{...stylex.props(styles.dotsContainer)}
- role="group"
+ // The dots already behave as an APG radio group (one Tab stop,
+ // arrows, Home/End, selection follows focus), so they expose its
+ // roles: a reader announces "Page 3, 3 of 7".
+ role="radiogroup"
aria-label={pageIndicatorsLabel}
onKeyDown={handleDotsKeyDown}
onFocus={handleDotsFocus}>
@@ -700,18 +709,23 @@ export function Pagination({
<button
key={i + 1}
type="button"
+ role="radio"
data-page={i + 1}
- aria-label={t('@astryx.pagination.goToPage', {
- page: i + 1,
+ aria-label={t('@astryx.pagination.pageAnnounce', {
+ current: i + 1,
})}
- aria-current={isActive ? 'page' : undefined}
+ // aria-checked carries the current page; aria-current beside
+ // it would announce the same state twice.
+ aria-checked={isActive}
// The active dot is the single roving tab stop; useListFocus
// maintains it as focus and the active page move.
tabIndex={isActive ? 0 : -1}
- // Selection is driven by focus (handleDotsFocus); clicking only
- // needs to focus the dot, which some browsers (Safari) skip for
- // buttons, so focus it explicitly.
- onClick={e => e.currentTarget.focus()}
+ // Focus selects the page (handleDotsFocus). The click focuses
+ // the dot, with the ring the last input calls for.
+ onClick={e => focusForLastInput(e.currentTarget)}
+ // A press must not choose a page before release. Sliding off
+ // takes it back. So the press does not focus the dot.
+ onMouseDown={e => e.preventDefault()}
// Disabled dots stay focusable (spec:AST-085 FR1); the page
// only follows focus while enabled (handleDotsFocus).
aria-disabled={isDisabled || undefined}
diff --git a/packages/core/src/RadioList/__tests__/RadioGroup.a11y.renders.tsx b/packages/core/src/RadioList/__tests__/RadioGroup.a11y.renders.tsx
index 0b97774fcd..70b784c8d9 100644
--- a/packages/core/src/RadioList/__tests__/RadioGroup.a11y.renders.tsx
+++ b/packages/core/src/RadioList/__tests__/RadioGroup.a11y.renders.tsx
@@ -16,6 +16,7 @@ import {
DropdownMenuRadioItem,
} from '../../DropdownMenu';
import {SegmentedControl, SegmentedControlItem} from '../../SegmentedControl';
+import {Pagination} from '../../Pagination/Pagination';
import {RadioList, RadioListItem} from '../index';
import type {RadioGroupStateId} from './RadioGroup.a11y.states';
@@ -148,6 +149,13 @@ function MenuRadioFixture({
);
}
+function PaginationDotsFixture() {
+ const [page, setPage] = useState(1);
+ return (
+ <Pagination page={page} onChange={setPage} totalPages={3} variant="dots" />
+ );
+}
+
export type RadioGroupStateRender = () => ReactElement;
export const RADIO_GROUP_STATE_RENDERS: Record<
@@ -212,6 +220,9 @@ export const RADIO_GROUP_STATE_RENDERS: Record<
/>
),
'segmented-option-unselected': () => <SegmentedFixture />,
+ 'pagination-dots-group': () => <PaginationDotsFixture />,
+ 'pagination-dot-unselected': () => <PaginationDotsFixture />,
+ 'pagination-dot-selected': () => <PaginationDotsFixture />,
'segmented-option-selected-hidden-label': () => (
<SegmentedFixture hideSelectedLabel />
),
diff --git a/packages/core/src/RadioList/__tests__/RadioGroup.a11y.states.ts b/packages/core/src/RadioList/__tests__/RadioGroup.a11y.states.ts
index d20110d5cb..d1ef3c1e3b 100644
--- a/packages/core/src/RadioList/__tests__/RadioGroup.a11y.states.ts
+++ b/packages/core/src/RadioList/__tests__/RadioGroup.a11y.states.ts
@@ -14,6 +14,8 @@ export type RadioGroupBinding =
| 'RadioListItem'
| 'SegmentedControl'
| 'SegmentedControlItem'
+ | 'Pagination dots'
+ | 'Pagination dot'
| 'DropdownMenuRadioGroup'
| 'DropdownMenuRadioItem';
@@ -386,6 +388,40 @@ export const RADIO_GROUP_BINDING_STATES = [
storyId: story('segmented-option-group-disabled-with-message'),
},
+ {
+ id: 'pagination-dots-group',
+ binding: 'Pagination dots',
+ summary:
+ 'the dots of a three-page Pagination as one radio group, page 1 current',
+ facts: groupFacts({visibleLabel: false}),
+ subjectName: 'Page indicators',
+ relations: {
+ first: {role: 'radio', name: 'Page 1'},
+ second: {role: 'radio', name: 'Page 2'},
+ third: {role: 'radio', name: 'Page 3'},
+ },
+ storyId: story('pagination-dots-group'),
+ },
+ {
+ id: 'pagination-dot-unselected',
+ binding: 'Pagination dot',
+ summary: 'a dot for a page that is not current',
+ facts: optionFacts({visibleLabel: false}),
+ subjectName: 'Page 2',
+ storyId: story('pagination-dot-unselected'),
+ },
+ {
+ id: 'pagination-dot-selected',
+ binding: 'Pagination dot',
+ summary: 'the dot for the current page, the roving Tab stop',
+ facts: optionFacts({
+ checked: true,
+ tabReachable: true,
+ visibleLabel: false,
+ }),
+ subjectName: 'Page 1',
+ storyId: story('pagination-dot-selected'),
+ },
{
id: 'menu-group-selected',
binding: 'DropdownMenuRadioGroup',
@@ -489,12 +525,6 @@ export const RADIO_GROUP_EXCLUSIONS = [
reason:
'TabMenu emits menuitemradio inside its menu-owned overflow navigation; it is not a standalone radio-group part.',
},
- {
- owner: 'Pagination dots',
- classification: 'out-of-scope',
- reason:
- 'Pagination dots are buttons in a named group with aria-current page semantics, not radio or radiogroup nodes.',
- },
{
owner: 'Home and End keyboard shortcuts',
classification: 'out-of-scope',
diff --git a/packages/core/src/RadioList/__tests__/RadioGroup.a11y.test.tsx b/packages/core/src/RadioList/__tests__/RadioGroup.a11y.test.tsx
index 54b179dea6..e0a7ce2c72 100644
--- a/packages/core/src/RadioList/__tests__/RadioGroup.a11y.test.tsx
+++ b/packages/core/src/RadioList/__tests__/RadioGroup.a11y.test.tsx
@@ -102,6 +102,8 @@ describe('the radio-group binding inventory', () => {
expect([...bound].sort()).toEqual([
'DropdownMenuRadioGroup',
'DropdownMenuRadioItem',
+ 'Pagination dot',
+ 'Pagination dots',
'RadioList',
'RadioListItem',
'SegmentedControl',
@@ -132,10 +134,6 @@ describe('the radio-group binding inventory', () => {
owner: 'TabMenu overflow choices',
classification: 'out-of-scope',
},
- {
- owner: 'Pagination dots',
- classification: 'out-of-scope',
- },
{
owner: 'Home and End keyboard shortcuts',
classification: 'out-of-scope',
@@ -201,6 +199,8 @@ describe('the radio-group binding inventory', () => {
const expected =
state.binding !== 'SegmentedControl' &&
state.binding !== 'DropdownMenuRadioGroup' &&
+ state.binding !== 'Pagination dots' &&
+ state.binding !== 'Pagination dot' &&
state.id !== 'segmented-option-selected-hidden-label';
return state.facts.visibleLabel !== expected;
}).map(state => state.id);