An open source design system that's fully customizable and agent ready
TypeScript
fix(Pagination): the ellipsis grows with a larger text size (#10567)
Cindy Zhanga1b0cd9ad7ec
diff --git a/.changeset/pagination-ellipsis-grows.md b/.changeset/pagination-ellipsis-grows.mdnew file mode 100644index 0000000000..08f3545ad3--- /dev/null+++ b/.changeset/pagination-ellipsis-grows.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] `Pagination`'s ellipsis grows with a larger text size, as its page buttons now do through `Button`. Its size is now a minimum height, so the "…" stays inside its own box. At the default text size nothing changes.++@cixzhangdiff --git a/docs/specs/components/Pagination/Pagination.spec.md b/docs/specs/components/Pagination/Pagination.spec.mdindex e9bcc8fe14..7864614e53 100644--- a/docs/specs/components/Pagination/Pagination.spec.md+++ b/docs/specs/components/Pagination/Pagination.spec.md@@ -111,7 +111,7 @@ Consumer migration instructions belong in consumer docs and release notes.| ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- || 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 |+| 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. Page number buttons grow with their label as `component:Button` FR4 says, and Ellipsis takes its size as a minimum height, so both grow with a larger text size and a wrapped row never covers another (`spec:AST-102` FR4). | Current source; `component:Button` FR4; `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 |@@ -266,7 +266,7 @@ does not decide whether it should remain unreachable.| 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` |-| FR15 | `PaginationTextSize.interaction.browser.spec.ts` at a 402 px viewport and 100%, 165% and 194% default font size | Pages; narrow viewport; default text size | A page that scrolls sideways, a control off screen, Previous not first or Next not last in reading order, or a second row at 100% fails. | `audit:Pagination/accessibility` |+| FR3, FR15 | `PaginationTextSize.interaction.browser.spec.ts` at a 402 px viewport and 100%, 165%, 194% and 312% default font size | Pages; narrow viewport; default text size | A page that scrolls sideways, a control off screen, Previous not first or Next not last in reading order, a second row at 100%, or a page number or ellipsis outside its box at 312% fails. | `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` |@@ -280,9 +280,9 @@ does not decide whether it should remain unreachable.- **Page-count docs (FR5, ORD1).** `totalPages` wins over the count derivedfrom `totalItems`, while the prop documentation says `totalItems` takesprecedence when both are given.-- **Delegated Button gaps (FR3).** The page and navigation Buttons scale on a- press under reduced motion and hold a fixed height, as `component:Button`- records, against `design:reduced-motion` DR1 and `spec:AST-102` FR4.+- **Navigation Button height (FR3).** Previous, Next, First, and Last keep a+ fixed square while their chevrons grow with a larger text size, against+ `spec:AST-102` FR4.- **Boundary and disabled focus (FR13).** Previous, Next, First, Last, and pagebuttons use native `disabled`, so a keyboard user on Next at the last pageloses focus, against `spec:AST-085` FR1, FR4, and FR7.diff --git a/packages/core/src/Pagination/Pagination.tsx b/packages/core/src/Pagination/Pagination.tsxindex b6bbaed03a..a2d8596e7c 100644--- a/packages/core/src/Pagination/Pagination.tsx+++ b/packages/core/src/Pagination/Pagination.tsx@@ -212,14 +212,14 @@ const styles = stylex.create({alignItems: 'center',justifyContent: 'center',minWidth: sizeVars['--size-element-md'],- height: sizeVars['--size-element-md'],+ minHeight: sizeVars['--size-element-md'],color: colorVars['--color-text-secondary'],fontSize: typeScaleVars['--text-label-size'],userSelect: 'none',},ellipsisSm: {minWidth: sizeVars['--size-element-sm'],- height: sizeVars['--size-element-sm'],+ minHeight: sizeVars['--size-element-sm'],fontSize: typeScaleVars['--text-supporting-size'],},infoText: {diff --git a/packages/core/src/Pagination/__tests__/PaginationTextSize.interaction.browser.spec.ts b/packages/core/src/Pagination/__tests__/PaginationTextSize.interaction.browser.spec.tsindex 053702227d..e35b8d7363 100644--- a/packages/core/src/Pagination/__tests__/PaginationTextSize.interaction.browser.spec.ts+++ b/packages/core/src/Pagination/__tests__/PaginationTextSize.interaction.browser.spec.ts@@ -97,3 +97,59 @@ for (const [size, px] of [expect(buttons[buttons.length - 1].name).toMatch(/next/i);});}++test('at 312% text size every page number stays inside its button', async ({+ page,+}) => {+ await setDefaultFontSize(page, 50);+ await page.goto(+ `${storybook.origin}/iframe.html?id=core-pagination--default&viewMode=story`,+ );+ await page.locator('nav button').first().waitFor();+ const fits = await page.evaluate(() =>+ [+ ...document.querySelectorAll<HTMLElement>(+ '#storybook-root nav button[aria-label*="page "]',+ ),+ ].map(button => {+ const range = document.createRange();+ range.selectNodeContents(button);+ const text = range.getBoundingClientRect();+ const box = button.getBoundingClientRect();+ return {+ name: button.getAttribute('aria-label') ?? '',+ above: box.top - text.top,+ below: text.bottom - box.bottom,+ };+ }),+ );+ expect(fits.length).toBeGreaterThan(0);+ for (const fit of fits) {+ expect(fit.above, fit.name).toBeLessThanOrEqual(1);+ expect(fit.below, fit.name).toBeLessThanOrEqual(1);+ }+});++test('at 312% text size the ellipsis stays inside its box', async ({page}) => {+ await setDefaultFontSize(page, 50);+ await page.goto(+ `${storybook.origin}/iframe.html?id=core-pagination--many-pages&viewMode=story`,+ );+ await page.locator('nav button').first().waitFor();+ const fits = await page.evaluate(() =>+ [...document.querySelectorAll<HTMLElement>('#storybook-root nav span')]+ .filter(span => (span.textContent ?? '').trim() === '\u2026')+ .map(span => {+ const range = document.createRange();+ range.selectNodeContents(span);+ const text = range.getBoundingClientRect();+ const box = span.getBoundingClientRect();+ return {above: box.top - text.top, below: text.bottom - box.bottom};+ }),+ );+ expect(fits.length).toBeGreaterThan(0);+ for (const fit of fits) {+ expect(fit.above).toBeLessThanOrEqual(1);+ expect(fit.below).toBeLessThanOrEqual(1);+ }+});