Repository navigation
feat(Pagination): page links through getPageHref - #11578
Conversation
Pagination's page number, previous, next, first and last controls were buttons wired only to onChange, so a page could not open in a new tab, be copied as a link, or work before scripts load. `getPageHref(page, pageSize)` returns each page's URL, and those controls render as links to it through Button's link mode. `as` sets the link component, and LinkProvider applies. The URL is the caller's, so a query parameter, a path segment, an offset or a cursor all work. `pageSize` is passed when the caller sets `pageSize` or `pageSizeOptions`. `onChange` is optional with `getPageHref` and still runs for a plain activation, with the link's click event as a second argument. A click that the browser opens elsewhere changes no page here. A disabled or unavailable control stays a button and asks for no URL. The dots, the page box and the page-size selector are not links: they keep their callbacks. A control with no link and no callback is disabled, with a development warning.
A link whose URL the navigation rule rejects renders with no `href`. Its click now changes no page, like a click that the browser opens elsewhere. A `target` of `_self` in any letter case counts as this tab. The docs and the record state the order of a page-size choice (`onPageSizeChange(size)`, then `onChange(1)`), and a test holds it. The record lists its open questions and the focus gap of a link at a boundary. The tests assert the exact URLs requested and the count of rejected links.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| DropdownMenu | 104.2 kB (0) · 18.5 kB CSS (0) | — | ✗ · ✓ · ✓ |
| DropdownMenuDivider | 5.3 kB (0) · 548 B CSS (0) | — | ✗ · ✓ · — |
| DropdownMenuGroup | 6.4 kB (0) · 3.4 kB CSS (0) | — | ✗ · ✓ · — |
21 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| DropdownMenuRadioGroup | 6.6 kB (0) · 3.3 kB CSS (0) | — | ✗ · ✓ · — |
| DropdownMenuSubMenu | 74.4 kB (0) · 10.1 kB CSS (0) | — | ✗ · ✓ · ✓ |
| DropdownMenuItem | 23.0 kB (−50 B) · 6.6 kB CSS (0) | — | ✗ · ✓ · — |
| DropdownMenuCheckboxItem | 23.8 kB (−53 B) · 7.0 kB CSS (0) | — | ✗ · ✓ · ✓ |
| DropdownMenuRadioItem | 23.9 kB (−66 B) · 7.0 kB CSS (0) | — | ✗ · ✓ · — |
| Pagination · Storybook | 121.1 kB (+262 B) · 18.8 kB CSS (0) | 701 (+34) | ✓ · ✓ · ✓ |
| BreadcrumbItem | 91.6 kB (0) · 12.9 kB CSS (0) | — | — · — · — |
| ContextMenu | 117.5 kB (0) · 18.3 kB CSS (0) | — | — · — · — |
| Markdown | 198.6 kB (0) · 21.5 kB CSS (0) | — | — · — · — |
| MoreMenu | 104.4 kB (0) · 18.5 kB CSS (0) | — | — · — · — |
| Table | 135.6 kB (0) · 19.2 kB CSS (0) | — | — · — · — |
| TableCell | 118.7 kB (0) · 18.8 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 118.3 kB (0) · 18.6 kB CSS (0) | — | — · — · — |
| lab/Comments | 367.5 kB (0) · 2.5 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 360.7 kB (0) · 2.4 kB CSS (0) | — | — · — · — |
| TabMenu | 78.6 kB (−5 B) · 11.9 kB CSS (0) | — | — · — · — |
| ContextMenuItem | 33.6 kB (−50 B) · 6.8 kB CSS (0) | — | — · — · — |
| SideNavItem | 76.7 kB (−60 B) · 11.9 kB CSS (0) | — | — · — · — |
| TopNavItem | 14.5 kB (−60 B) · 4.0 kB CSS (0) | — | — · — · — |
| TopNavMegaMenuItem | 14.2 kB (−61 B) · 4.2 kB CSS (0) | — | — · — · — |
| TopNavMenu | 81.3 kB (−69 B) · 12.0 kB CSS (0) | — | — · — · — |
Visual changes: 4 snapshots in 1 component
A change is a question for the reviewer, not a failure.
Package size: @astryxdesign/core 7.52 MB packed (+3.7 kB); no new dependencies.
API changes: core +2 · ~0 · −0
2 API changes (advisory)
| Package | Where | Signature | Usage | |
|---|---|---|---|---|
| + | core |
. · Components · component Pagination |
prop as?: LinkComponentType |
<Pagination as={…} /> |
| + | core |
. · Components · component Pagination |
prop getPageHref?: (page: number, pageSize?: number) => string |
<Pagination getPageHref={…} /> |
Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Approval waits on an engineering owner's decision on the proposed component:Pagination changes, and four fixes are needed either way.
An engineering owner records that decision by commenting /approve-spec <full head SHA>; the author may do so as an engineering owner. It covers DEC-1, DEC-2 and FR16–FR19, the open questions OQ3–OQ5, and whether a page link may lose focus at a boundary against spec:AST-085 FR4.
- Making
onChangeoptional breaks TypeScript wrappers that callprops.onChange(page)(TS2722), so the record's "additive" compatibility class, the description and the patch changeset must either state the break or keep the released type. - With no link and no callback, Previous, Next, First and Last are disabled but keep their tooltips (
Pagination.tsx:951,:969,:987,:1004), against FR12's "tooltip only while available". - The record now says both that button controls keep focus at a boundary (FR16 and Current-state impact) and that they are natively disabled and drop focus (FR13, the End-user impact, Compatibility and Disabled rows), so one side needs correcting.
- OQ4 says DropdownMenuItem link rows skip their handler for clicks that open elsewhere, but they skip only modified clicks (
DropdownMenuItem.tsx:229), not plain clicks ontarget="_blank"rows.
Claims and files checked
- Claim: with the URL function set, page numbers, Previous, Next, First and Last render as links — verified (page-link tests; a real anchor with its URL in Chromium).
- Claim: a page link opens in a new tab, copies, and works before scripts load — verified from the code (Button renders a real anchor in the server markup).
- Claim: the URL takes the app's shape and receives the page size only when one is set — verified (tests for unset, set size and size options).
- Claim: the link component comes from the new prop, else the link provider — verified (tests, the prop winning).
- Claim: the page-change callback is optional, still runs for each page change, and gets the click event from a link — verified (tests).
- Claim: the dots, the page box and the page-size selector stay controls — verified (tests).
- Claim: a Pagination without the URL function is unchanged — verified at runtime; the callback's type change is the first finding above.
- Claim: the change is additive — false (a wrapper that calls the callback stops compiling).
- Claim: menu link rows skip their handler for clicks that open elsewhere — false for new-tab targets (only modified clicks are skipped).
- Claim: tabs and buttons run their handlers for every click — verified (source).
- Claim: a focused link at a boundary loses focus while a button keeps it — verified (Chromium frames).
- Claim: a Pagination with no callback now type-checks and is disabled with a warning — verified (test).
- Claim: no visual change — verified in Chromium at rest and with focus (identical frames); Firefox and WebKit not rerun.
- Claim: 32 new tests, the existing suite unchanged, 138 passing; typecheck, lint and repository checks pass — verified.
- Claim: the mutation check, the full-suite run and the precedent in other libraries — not rerun or outside this repository.
- File:
Pagination.tsx— findings (tooltips on disabled carets; callback type change). - File:
Pagination.spec.md— findings (compatibility class, focus contradiction, menu precedent). - File:
.changeset/pagination-page-links.md— finding (described as additive and filed as a patch). - File:
Pagination.doc.mjs— clear. - File:
Pagination.test.tsx— clear. - File:
Pagination.stories.tsx— clear. - File:
docs/families/navigation-destinations.md— clear (its membership rule requires the entry).
Previous, Next, First and Last kept their tooltip when they were disabled for having no link and no callback. The tooltip now follows the same disabled value as the control. The record said in six places that the Buttons are natively disabled and drop focus at a boundary. They use `aria-disabled` and keep focus, and a test now holds that. The one focus gap is a page link that becomes unavailable: a disabled button replaces it. The open question on clicks that open elsewhere now says what DropdownMenuItem link rows do: they skip their handler for a modified click, not for a `target`.
There was a problem hiding this comment.
Approval waits on an engineering owner's decision on the proposed component:Pagination changes, and one fix is needed either way.
An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner. It covers DEC-1, DEC-2 and FR16–FR19, the open questions OQ3–OQ5, and whether a page link may lose focus at a boundary against spec:AST-085 FR4.
- Making
onChangeoptional breaks TypeScript wrappers that callprops.onChange(page)(TS2722), so the record's "additive" compatibility class, the description and the patch changeset must either state the break and file it as[breaking](minor, perspec:AST-017FR7 and FR25) or keep the released type.
The tooltip, focus-wording and menu-precedent fixes from the last review are in.
Claims and files checked
- Claim: with the URL function set, page numbers, Previous, Next, First and Last render as links — verified (page-link tests; anchors with their URLs in Chromium).
- Claim: a page link opens in a new tab, copies, and works before scripts load — verified from the code (Button renders a real anchor in its server markup).
- Claim: the URL takes the app's shape and gets the page size only when one is set — verified (tests for an unset size, a set size and size options).
- Claim: the link component comes from the new prop, else the link provider — verified (tests; the prop wins).
- Claim: the page-change callback is optional, runs for each page change, and receives the click event from a link — verified (tests).
- Claim: a modified click, a link that opens in another target, or a rejected URL changes no page — verified (tests).
- Claim: the dots, the page box and the page-size selector stay controls, and a size choice reports the size and then page 1 — verified (tests).
- Claim: a control with no link and no callback is disabled, shows no tooltip and warns — verified (tests).
- Claim: a Pagination without the URL function is unchanged — verified at runtime; the callback's type change is the finding above.
- Claim: the change is additive — false (a wrapper that calls the callback stops compiling).
- Claim: menu link rows skip their handler only for modified clicks, and tabs and buttons run theirs for every click — verified (source).
- Claim: a button control keeps focus at a boundary while a page link loses it — verified (Chromium in this review; the new focus test).
- Claim: no visual change — verified in Chromium at rest and with keyboard focus on Next (pixel-identical frames); Firefox and WebKit not rerun.
- Claim: 34 new tests, 106 existing tests unchanged, 140 passing; typecheck, lint and the record and changeset checks pass — verified.
- Claim: the Storybook typecheck, the full-suite run, the pre-review tool run and the mutation check — not rerun.
- Claim: the six focus statements and the menu precedent in the record are corrected — verified.
- File:
Pagination.tsx— finding (callback type change); a non-blocking comment note. - File:
Pagination.spec.md— finding (compatibility class says additive). - File:
.changeset/pagination-page-links.md— finding (filed as a patch feature). - File:
Pagination.doc.mjs— clear. - File:
Pagination.test.tsx— clear. - File:
Pagination.stories.tsx— clear. - File:
docs/families/navigation-destinations.md— clear (its membership rule requires the entry).
`onChange` is required again and receives the page alone, as before page links. A plain click on a page link calls `onChange(page)` as a button control does, and the link navigates. A wrapper that calls `props.onChange(page)`, an interface that extends `PaginationProps`, and a handler with its own second parameter all compile as they did. With `onChange` required, a control always has a callback. The disabling of a control with no link and no callback, its development warnings and their tests are gone, and the tooltips follow availability as before. The record states the click rule as a requirement: a click that does not navigate this document changes no page here. It records the `onChange` decision and has no open question left on it. The docs say where an app navigates: not in `onChange` when the controls are links, and in `onPageSizeChange` for a page-size choice.
There was a problem hiding this comment.
Approval waits on an engineering owner's decision on the proposed component:Pagination changes, and one fix is needed either way.
An engineering owner records that decision, covering DEC-1 to DEC-3, FR16–FR18 and Pagination joining family:navigation-destinations, by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.
- Miss: a focused Previous, Next, First or Last link that reaches the first or last page is replaced by a disabled button and focus falls to the page, against
spec:AST-085FR4, which approving the Pagination record does not amend, so move focus before the change to a destination FR16 names (the target page's link, else the opposite arrow) or have AST-085 amended here.
The onChange type break and the earlier tooltip, focus-wording and menu-precedent points are resolved; CI has not run on this draft head.
Claims and files checked
- Claim: with the URL function set, the page number, previous, next, first and last controls render as links — verified (page-link tests; anchors with their URLs in Chromium).
- Claim: a page link opens in a new tab, copies, and works before scripts load — verified from the code (Button renders a real anchor in its server markup).
- Claim: the URL function gets the page, and the page size only when one is set, and may return any URL shape — verified (tests for an unset size, a set size, size options, an empty option list and cursor paging).
- Claim: the link-component prop sets the link component, and the link provider applies — verified (tests; the prop wins).
- Claim: a plain click or Enter on a link runs the page change (callback, announcement, async action) and is never cancelled — verified (test; Enter activates an anchor through its click).
- Claim: a modified click, a link that opens in another target, or a rejected URL changes no page — verified (tests).
- Claim: an unavailable end, and every control while disabled, stays a disabled button and asks for no URL — verified (tests).
- Claim: cursor paging asks for the pages before and after the current one — verified (tests).
- Claim: the dots, the page box and the page-size selector stay controls, and a size choice reports the size and then page 1 — verified (tests).
- Claim: the page-change callback keeps its released, required, page-only type, so wrappers and extending interfaces compile and leaving it out is a type error — verified from the declaration; no compile probe was run.
- Claim: a Pagination without the URL function is unchanged, with no theming change — verified (unchanged path; pixel-identical Chromium frames).
- Claim: no visual change — verified in Chromium at rest and with keyboard focus on Next; Firefox and WebKit not rerun.
- Claim: a button control keeps focus at a boundary while a page link loses it — verified (the new unit test; Chromium in this review).
- Claim: 28 new tests, 106 existing tests unchanged, 134 passing, Core typecheck passing, 880 authored lines — verified.
- Claim: the Storybook typecheck, lint, repository checks, pre-review tool, full-suite run, mutation check, existing browser specs and the Firefox and WebKit runs — not rerun.
- Claim: other libraries use the same URL-function design — not checkable from this repository.
- File:
Pagination.tsx— finding (boundary focus); two non-blocking comment notes. - File:
Pagination.spec.md— FR16 records the focus gap the finding names; the rest waits on the owner decision. - File:
Pagination.test.tsx— clear. - File:
Pagination.doc.mjs— clear. - File:
Pagination.stories.tsx— clear. - File:
.changeset/pagination-page-links.md— clear. - File:
docs/families/navigation-destinations.md— clear (its membership rule requires the entry).
A control that stops or starts being a link while it holds focus keeps that focus. Button replaces a link with a disabled button when the control becomes unavailable, at the first or last page or while the pagination is disabled, and the document dropped the focus of the link. Pagination now notes the focus before the replacement and moves it to the new element in the same commit, with the focus ring that the last input calls for. The browser follows the URL of the Previous or Next link that was activated. The page change gave the link its next URL before the browser followed it, so a plain anchor went one page too far. Previous and Next now count from the page of the click until the click is over. A new browser spec covers both in Chromium and WebKit, with a story whose links navigate through a client-side router.
|
/approve-spec 48d5b92 |
… hook A Pagination control keeps focus when Button replaces its element through `useFocusAcrossSwap`, the hook that Item, TreeListItem and NavHeadingMenuItem use for the same replacement. The control calls it once, and the snapshot wrapper is gone. The hook is not changed. The browser spec adds the pointer case: after a click takes a Next link to the last page, the button that replaces it holds focus without the ring. The file header is shorter.
|
/approve-spec 32d2ab4 |
There was a problem hiding this comment.
Changes are needed before approval. An engineering owner approved the proposed component:Pagination and navigation-family record changes at this head, so one fix remains.
- Newly live check: the page-link wiring loads with every Pagination and adds 338 B gzip of first-load JavaScript to a page that renders Pagination without
getPageHref, over the 0.3 KB that the component import boundaries record allows an unused optional feature, so move it behind its own import or a deferred load, or trim it under 0.3 KB (takingisModifiedClickwithout the menu selector setup inmenuItemRolesbrings it to about 280 B), and report the base-against-head first-load gzip delta in the description.
Last review's points are fixed: each control now calls useFocusAcrossSwap once, and the test counts match the head. The page-link browser spec passes in Chromium, and the CI checks that have finished on this head pass.
Claims and files checked
- Claim: with the URL function set, the page number, previous, next, first and last controls render as links. Verified by the page-link tests and by anchors in Chromium.
- Claim: a page link opens in a new tab, its address copies, and it works before scripts load. Verified from the code: Button renders a real anchor with the URL in its server markup.
- Claim: the URL function gets the page, gets the page size only when the caller sets one, and may return any URL shape, cursor paging included. Verified by tests.
- Claim: the link-component prop sets the link component, and the link provider applies too. Verified by tests.
- Claim: a plain click or Enter on a link runs the page change and is never cancelled. Verified by test.
- Claim: the browser follows the URL that was activated, and a new key or pointer press counts from the new page. Verified by tests and by the browser spec in Chromium.
- Claim: a modified click, a link with another target, or a rejected URL changes no page. Verified by tests.
- Claim: a control that stops or starts being a link while focused keeps focus, with the ring for the last input, and a control that did not hold focus takes none. Verified by tests, the browser spec in Chromium and capture probes.
- Claim: an unavailable end, and every control while disabled, stays a disabled button and asks for no URL. Verified by tests.
- Claim: the dots, the page box and the page-size selector stay controls, and a size choice reports the size and then page 1. Verified by tests.
- Claim: the page-change callback keeps its released type, and only two optional props are added. Verified from the unchanged declaration and the API generator's two added rows.
- Claim: each control calls the shared focus-across-swap hook once, and the hook and Button are unchanged. Verified from the source and the diff.
- Claim: a Pagination without the URL function is unchanged. Verified for rendering and behavior (the base branch's 106 tests pass on this head, frames identical); its first-load size grows (finding above).
- Claim: no visual change. Verified in Chromium with pixel-identical frames; Firefox and WebKit were not rerun.
- Claim: 46 new unit tests, 152 in the file, 1,604 authored lines, and the typecheck, lint and knowledge checks pass. Verified.
- Claim: the browser spec's 9 tests pass in Chromium, WebKit and Firefox. Verified in Chromium; WebKit and Firefox were not run.
- Claim: the mutation check, the full test run, the Storybook typecheck, the other hook callers' tests and the older browser specs pass. Not rerun.
- Claim: other libraries take the same URL-function route. Not checkable from this repository.
- Claim: the spec owner's sign-off covers the record changes. Verified: an engineering owner approved this head.
- File:
packages/core/src/Pagination/Pagination.tsx: the first-load finding; a non-blocking note onPaginationButton's JSDoc. - File:
packages/core/src/Pagination/Pagination.test.tsx: clear. - File:
packages/core/src/Pagination/__tests__/PaginationLinks.a11y.browser.spec.ts: clear (passes in Chromium). - File:
docs/specs/components/Pagination/Pagination.spec.md: clear (approved at this head; consistent with the code). - File:
docs/families/navigation-destinations.md: clear (its membership rule requires the entry). - File:
packages/core/src/Pagination/Pagination.doc.mjs: clear. - File:
apps/storybook/stories/Pagination.stories.tsx: clear. - File:
.changeset/pagination-page-links.md: clear.
A Pagination without `getPageHref` now loads 260 B gzip more than it did before page links. It was 338 B. `menuItemRoles` builds each selector in a call marked pure, so a bundler drops the selectors that an import does not use. Pagination takes `isModifiedClick` from that module and loads no selector with it. A page that uses the selectors loads the same bytes as before. The link wiring in Pagination is smaller, with the same behavior. One expression gives a control its URL. The click handler returns early for a click that opens the URL elsewhere. The timer that ends the URL hold needs no null checks.
|
/approve-spec bef0871 |
There was a problem hiding this comment.
Approved pending CI: CI has not finished on this head yet. Its first run was cancelled because CI was full, and a re-run is in progress; merge waits for it.
An engineering owner approved the component:Pagination and navigation-destinations record changes at this head, and the earlier size finding is fixed: a page that renders Pagination without getPageHref now loads 260 B more gzip, within the 0.3 KB allowance, and the shared menu module costs the four reference pages nothing. The page links follow the clicked URL and keep focus at the first and last page in Chromium, and the frames at rest are pixel-identical to the buttons.
Claims and files checked
- Verified: passing
getPageHrefmakes the page number, previous, next, first and last controls links (Pagination.tsx:615-637, page-link tests, 7 links in the Page links story). - Verified:
aspicks the link component andLinkProviderapplies, withaswinning (unit tests). - Verified:
onChange(page)still runs for a plain link click, and its type is unchanged (Pagination.tsx:83,:634, unit test). - Verified: the browser follows the activated URL, because Previous and Next keep their URL until the click is over (
Pagination.tsx:509-517,:629-632; unit tests; Chromium follows page 2, page 4, page 3, and page 8 at the last page). - Verified: a modified click, a link whose target is not
_selfand a rejected URL change no page (Pagination.tsx:389-398, unit tests). - Verified: a control that stops or starts being a link keeps focus, with the ring after a key press and none after a pointer press (
Pagination.tsx:403-406, unit tests, Chromium probes). - Verified: the dots, the page box and the page-size selector stay controls, and cursor paging asks for the page before and after the current one (unit tests).
- Verified: the menu module's selectors are pure calls a bundler drops, so Pagination's import carries none (
menuItemRoles.ts:24,:34, bundle test). - Verified: a page without
getPageHrefgrows from 119,219 to 119,479 B gzip (+260 B), and the docs, form, menu and table pages are unchanged; the earlier head's +338 B matches the earlier measurement. - Verified: 46 new tests, 152 in the file, and the base's 106 pass unchanged; the authored size is 1,693 lines.
- Verified:
onChangestays required with its released type, so a wrapper that calls it compiles and a Pagination without it does not. - Verified: no visual change: base buttons and head links give identical Chromium frames at rest and at the last page.
- Verified: the shared focus hook and Button are unchanged; the changeset describes the same behavior, and a Pagination without
getPageHrefis unchanged. - Not rechecked: the 21-mutation run, the WebKit and Firefox runs, and the other callers' test runs.
.changeset/pagination-page-links.md: clear.apps/storybook/stories/Pagination.stories.tsx: clear.docs/families/navigation-destinations.md: clear.docs/specs/components/Pagination/Pagination.spec.md: clear.packages/core/src/DropdownMenu/menuItemRoles.test.ts: clear.packages/core/src/DropdownMenu/menuItemRoles.ts: clear.packages/core/src/Pagination/Pagination.doc.mjs: clear.packages/core/src/Pagination/Pagination.test.tsx: clear.packages/core/src/Pagination/Pagination.tsx: clear.packages/core/src/Pagination/__tests__/PaginationLinks.a11y.browser.spec.ts: clear.scripts/menu-item-roles-bundle.test.mjs: clear.












User need
Someone reading a paged list expects each page to be a destination: open page 7 in a new tab, copy its address, reach it before scripts load. Pagination's page number, Previous, Next, First and Last controls are buttons wired only to
onChange, so none of that works.Buttoncan render a link (href,as), but Pagination gives a caller no way to hand its Buttons a URL.Buttonlinks andgeneratePageRange, and keep its look, names and disabled ends in step by hand. The docs site needs this for its changelog, where each page of releases has its own URL.hrefis not enough: apps address a page differently (a query parameter, a path segment, an offset, a cursor, page 1 with no parameter), so the URL has to come from the caller.Problem and solution fit
getPageHref(page, pageSize)asLinkProviderapplies too.onChange(page)also runs for a plain link click<a>Next link went one page too far.spec:AST-085FR4).menuItemRoles: each selector is a call marked pureisModifiedClickfrom that module. Its two selector constants ran when the module loaded, so every Pagination page carried them. A bundler now drops the ones an import does not use.No tagalongs.
Current specification
The spec owner's sign-off covers DEC-1 to DEC-3, FR16 to FR19, and Pagination joining
family:navigation-destinations. Nothing else is left to decide.Owner decisions (
nynexman4464, 2026-11-13), recorded in this pull request ascomponent:PaginationDEC-1, DEC-2 and DEC-3:getPageHref, and Pagination takesas.pageSizeorpageSizeOptions, otherwiseundefined.onChangeruns for a link click, as it does for a button control.onChangestays required, with its released type. It gains no second argument.Existing authority the change relies on:
component:ButtonFR10 and FR11: link mode throughas, thenLinkProvider, then a native anchor; a disabled Button withhrefis a<button>that runs noonClick.family:navigation-destinationsFR1, FR2, FR7 and its membership rule: Pagination joins the family; Button anduseLinkComponentdecide each destination.architecture:public-component-apiINV2 and DEC-1 (hrefandasare the system's words), INV4 withspec:AST-002DEC-1 (only the caller knows its URL shape), INV18 and INV21 (no per-item props, render function or compound parts beside the existing API).spec:AST-085FR4 and FR7: a control that becomes disabled while it holds focus keeps focus. Its verification row names Pagination's last page, and focus on the document body fails.architecture:interaction-modalityINV1: a focus that script moves shows the indicator the last input calls for.The type break raised in review is resolved by keeping the released type.
PaginationPropsstays an interface, andonChange: (page: number) => voidis the same as on the base. The only public additions are two optional props.The browser follows the URL that was activated (FR17). A link click changes the page, and React renders the Previous and Next links with their next URLs before the browser follows the link. With a plain
<a>, a Next link on page 2 then went to page 4. Every earlier head of this pull request had this; a link component that navigates on the client did not, because it reads itshrefprop. Previous and Next now count from the page of the click until the click is over. The next task releases that, and so does a key or pointer press that arrives sooner, so a second activation counts from the new page.A page link keeps focus (FR19). Button replaces a link with a disabled
<button>when the control becomes unavailable, and puts the link back when it is available again. Pagination now moves the focus across that replacement, so the control holds focus afterwards as a button control does. Each control calls Core's shared hook for this replacement once,useFocusAcrossSwap, the one Item, TreeListItem and NavHeadingMenuItem use (architecture:react-component-runtimeINV16). The hook notes the focus when React detaches the old element, and focuses the new one in the same commit, only when the document dropped the focus. The hook and Button are not changed.Public delta and caller burden
Behavior with
getPageHref, and the clause that states it:pages,count,compact,none, and the arrows ofdotsandinput). Names are unchanged; the current page keepsaria-current="page". An unavailable end, and every control underisDisabled, stays a disabled button, and Pagination asks for no URL for it (FR16).onChange(page), announcement,changeAction, optimistic page), and then the link navigates. Pagination never cancels the click (FR17, DEC-1).targetis not_self, and a link whose URL the shared navigation rule rejects. The page of this document did not change, soonChangedoes not run and nothing is announced (FR17).isDisabledis on, and the way back. The focus ring follows the last input: shown after a key, not after a pointer. A control that did not hold focus takes none (FR19).Compatibility: additive. A Pagination without
getPageHrefrenders and behaves as before. No theming change: a link is the same Button target.Before, a page is reachable only through script:
After, each page is a link. The app's link component (
LinkProvider, oras) owns client-side navigation, replace or push, and prefetch.onChangeis for state or analytics and does not navigate:With a page-size selector, the app navigates for a size choice in
onPageSizeChange, never in theonChange(1)that follows:Decisions the caller makes:
onChangewhengetPageHrefis set.onChangedoes not say which control changed the page.onChangefor the dots or the page box leavesgetPageHrefunset in thedotsandinputvariants. With it set, their arrow links would navigate andonChangewould navigate again.Design and alternatives
A URL function keeps the page range, names, current page and disabled ends inside Pagination and leaves only the URL to the caller. Primer (
hrefBuilder) and Ark UI (getPageUrl) take the same route.Rejected:
getItemProps): the caller reaches into Button's props and has to work out the Previous and Next targets.renderItem, Ant DesignitemRender): the caller owns each control's markup, andasandLinkProvideralready swap the element.onChangewhere every control is a link (DEC-3): its type would depend on the variant and onpageSizeOptions, and a wrapper that callsprops.onChange(page)stops compiling.onChangeargument that names the control (DEC-3): a handler with its own second parameter stops compiling.Evidence
Unit tests. 46 new cases in
Pagination.test.tsx(152 in the file). Links: each link and its URL,step, the page-size argument (unset,pageSize,pageSizeOptions, an empty option list),as,LinkProvider, the exact URLs requested at each boundary and while disabled, cursor paging, a rejected URL, plain, modified andtargetclicks, oneonChange(page)call for a plain link click, the dots and the page box withgetPageHref, the order of a page-size choice, and tooltips on link controls. The followed URL: a clicked Previous or Next link keeps its URL until the click is over, a second click in the same task repeats the page, a key or pointer press releases it, its timer is released on unmount, and a button control is unchanged. Focus: First, Previous, Next and Last links that reach a boundary, a link component,isDisabledon and off, a page the caller sets, a page that arrives after the click, another control used, focus elsewhere, and focus that left the control earlier.First-load size without
getPageHref. A page that renders Pagination and never passesgetPageHrefloads 119,219 B gzip of JavaScript on the merge base and 119,479 B on this head: +260 B, under the 0.3 KB thatarchitecture:component-import-boundariesINV10 allows an unused optional feature. The head before this one was at +338 B. Measured on each commit with the repository's size-report build of the Pagination entry:The shared
menuItemRolesmodule does not grow. Each of INV10's four reference pages (docs, form, menu, table), built the same way, loads the same bytes with the base copy of that module and with this one: +0 B on each. The docs and form pages do not reach it. Two new tests pin the module: its selector values, and that an import ofisModifiedClickcarries no role set and no selector.Mutation check. 21 single-line mutations on this head, over the lines its last commit changes: the click guard (a rejected URL,
_self, its case, a modifier key), the URL of a disabled or unavailable control, the page-size argument, a link click that skips or always runs the page change, the URL hold (not set, set from the new page, not released by time, by a key or by a pointer press), its timer left behind at the next click or on unmount, the shared hook's ref left off, and inmenuItemRolesa selector that is not marked pure or has the wrong value. Each fails at least one test. Earlier heads ran 46 and 17 over the rest of the link code, all caught.Links in real browsers. A new committed spec,
PaginationLinks.a11y.browser.spec.ts, drives the built stories with real key and pointer input: the URL the browser follows for Next and Previous (Enter and click, back to back), a button control at the last page, Next and Previous links of a plain<a>that reach a boundary, and the links of a client-side router that disables the control while it navigates (a new story, "Page links (client-side router)"). The focus cases assert that the control holds focus after every change to the landmark, with the ring after a key press and without it after a pointer click. 9 tests pass in Chromium 149 and WebKit 26.5, and in Firefox 151 with the same spec under a scratch project, three repeats each. On an earlier head, without the focus move, the link focus cases failed with focus on<body>, and without the URL hold, the first click on Next from page 1 went to#page-3in all three engines.Types. With the repository's TypeScript on a scratch file against the component: a wrapper that calls
props.onChange(page)onPaginationPropscompiles;interface X extends PaginationPropscompiles; a handler(page: number, replace?: boolean) => voidpassed asonChangecompiles;<Pagination page={1} totalPages={5} />is an error (TS2741,onChangeis missing).No visual change. The same story with and without
getPageHref, compared pixel by pixel at 2x: numbered and dots variants, light and dark, in four states (page 1, a middle page, pointer on Next, keyboard focus on Next). 0 different pixels in all 16 comparisons in Chromium 149, in Firefox 151 and in WebKit 26.5, with the links present in the DOM (7 on the numbered story). The four states differ from each other by hundreds to thousands of pixels, so the comparison can see a change.Unchanged paths. The 106 existing Pagination tests pass unchanged, and the base branch's copy of the test file passes against this head (106 of 106). The tests of the shared hook's other callers pass (the Item, NavMenu and TreeList folders: 300 tests), and so do the tests of every folder that imports
menuItemRoles(DropdownMenu, ContextMenu, Breadcrumbs, TabList, NavMenu, AppShell and Pagination: 916 tests). The existing browser specs that load Pagination stories pass in Chromium (RadioGroup.a11y.chromium.spec.ts, 31 passed;PaginationTextSize.interaction.browser.spec.ts, 5 passed).Scope
Components: Pagination. One internal module that it imports also changes:
DropdownMenu/menuItemRoles.ts.Testing
The full run's two failing files import nothing this change touches, and every failure is a 30 s timeout.
.github/scripts/lib/offline-media.test.mjs(2 tests) waits on an unreachable remote host from this machine's network, and fails the same way on the base branch.packages/cli/foundation/doc-compiler/stored-docs.test.mjs(1 test) times out under the full run's load; run alone, the file passes on this branch and on the base branch (7 tests).Not done: no real-browser test of a click that opens elsewhere (a modifier key or a
target). The unit tests cover it, and the Pagination record lists the gap.Writing rubric results