feat(pager): align with Fusion DS#8010
Conversation
There was a problem hiding this comment.
Pull request overview
Aligns the Pager component with Fusion DS Pagination, updating styling/tokens, interaction patterns, accessibility labels, and the public API surface (including a new size prop and deprecations of several legacy props/translation keys).
Changes:
- Replaces link-based navigation with button-based navigation and introduces Fusion-aligned sizing/styling.
- Updates i18n model: adds new aria/label keys and deprecates older pager translation keys.
- Updates unit tests, Playwright tests, stories, and docs to match the new UI/behavior.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/locales/locale.ts | Updates pager locale typings, adds new keys and deprecates old ones. |
| src/locales/en-gb.ts | Implements new pager translation keys for en-GB. |
| src/components/pager/pagination.style.ts | Adds new Fusion-aligned pager styles (nav container + page size area). |
| src/components/pager/pagination.component.tsx | Introduces new Pagination implementation (exported as Pager). |
| src/components/pager/internal/pagination-navigation.style.tsx | Adds styling for navigation buttons and current page input layout. |
| src/components/pager/internal/pagination-navigation.component.tsx | Implements button navigation + current-page input behavior and a11y. |
| src/components/pager/index.ts | Switches default export to the new Pagination component and aliases props type. |
| src/components/pager/pager.test.tsx | Reworks unit tests for the updated behavior and new aria-labels. |
| src/components/pager/pager.pw.tsx | Updates/rewrites Playwright tests for focus management and a11y coverage. |
| src/components/pager/components.test-pw.tsx | Updates Playwright mount component for the new Pager behavior. |
| src/components/pager/pager.stories.tsx | Updates stories to reflect new API/behavior and adds size variants. |
| src/components/pager/pager-test.stories.tsx | Updates test stories for broader visual/viewport coverage of new variants. |
| src/components/pager/pager.mdx | Updates component docs and translation keys table. |
| src/components/pager/pager.component.tsx | Removes the legacy Pager implementation. |
| src/components/pager/pager.style.ts | Removes legacy Pager styling. |
| src/components/pager/internal/pager-navigation.component.tsx | Removes legacy navigation implementation. |
| src/components/pager/internal/pager-navigation-link.component.tsx | Removes legacy link-based navigation helper. |
| src/components/pager/internal/pager-navigation.test.tsx | Removes legacy navigation tests. |
| src/components/flat-table/flat-table.style.ts | Updates footer styling hooks to target the new pager root component. |
| src/components/flat-table/flat-table.test.tsx | Updates Pager imports/usages in FlatTable tests. |
| src/components/flat-table/flat-table.pw.tsx | Removes FlatTable pager-navigation Playwright tests tied to the old implementation. |
| src/internal/input/input.style.ts | Removes legacy pager-specific input overrides hook. |
| src/internal/input/input-style-overrides.style.ts | Deletes legacy pager input override CSS blocks. |
| src/internal/input-icon-toggle/input-icon-toggle.style.ts | Removes pager-specific icon-toggle overrides. |
| skills/carbon-react/components/pager.md | Updates skills docs for new Pager/Pagination API details. |
| if (+totalRecords < 0 || Number.isNaN(+totalRecords)) { | ||
| return 1; | ||
| } | ||
| return Math.ceil(+totalRecords / internalPageSize); | ||
| }, [totalRecords, internalPageSize]); |
There was a problem hiding this comment.
When totalRecords is 0, output is "0 of 0 pages" as the current page can never be larger than the total. This change is unnecessary.
| ariaLabel?: () => string; | ||
| // TODO - make the following keys required once deprecated keys are removed. | ||
| pageX: (currentPage?: number | string) => string; | ||
| ofTotalPages?: (totalPages: string | number) => string; | ||
| itemsPerPage?: () => string; |
There was a problem hiding this comment.
Translations will be provided at a later date, consumers can set the translations themselves if necessary.
I have removed the deprecated translations that are no longer in use in all locales and added currentPage prop to translation key pageX.
| name: "pager.previousAriaLabel", | ||
| description: | ||
| "The text to display for the button that navigates to the last page of records", | ||
| "Accessible label for the 'Go To Next' button.", | ||
| type: "func", | ||
| returnType: "string", |
| ## Source | ||
| - Export: `./components/pager` | ||
| - Props interface: `PagerProps` | ||
| - Props interface: `PaginationProps` | ||
|
|
There was a problem hiding this comment.
.md files cannot be manually updated, I have reverted the interface name to PagerProps and added a TODO for this to be updated once the public interface it updated as a breaking change.
There was a problem hiding this comment.
suggestions: Beware of conflicts with the FlatTable testing optimisation stuff @sianford is currently doing with FlatTable.
|
This work will close the following issue as it will be superseded by this updated Pager/Pagination. |
| previous: () => "Vorherige", | ||
| pageX: () => "Seite", | ||
| ofY: (count) => `von ${count}`, | ||
| pageX: (currentPage?: number | string) => `Seite ${currentPage}`, |
There was a problem hiding this comment.
comment: frustrating that we lose i18n support for this component again
Not a lot we can do about it, as it's not worth blocking while waiting for translations, but I wonder if this will cause issues for consuming teams
|
UXQA:
|
e120c0d to
def6ed2
Compare
There was a problem hiding this comment.
Warning
- Copilot's review of this pull request may be incomplete because some of the changed files are excluded by your Copilot content exclusion settings. See Excluding content from Copilot for details.
Pull request overview
Copilot reviewed 30 out of 30 changed files in this pull request and generated 3 comments.
Files excluded by content exclusion policy (1)
- skills/carbon-react/components/pager.md
Aligns to Pagination component in Fusion DS, Pager to be renamed to Pagination in a future release. Deprecates props that are no longer relevant, updates styles with fusion-tokens and updates translation keys.
|
🎉 This PR is included in version 159.15.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Proposed behaviour
Alignes
Pagerto Fusion DSPaginationcomponent.sizeprop:Deprecated props:
hideDisabledElementsshowPageSizeLabelBeforeshowPageSizeLabelAftershowTotalRecordsshowPreviousAndNextButtonsshowPageCountsmallScreenBreakpointCurrent behaviour
Pageris not aligned with Fusion DS.Checklist
d.tsfile added or updated if requiredQA
Additional context
Testing instructions