Repository navigation
[Paginator] Announce the page status to screen readers - #5475
Denis Voituron (dvoituron) merged 7 commits into
Conversation
The "Page X of Y" text is now a polite status live region, so screen readers announce the new page when the user navigates between pages. Fixes microsoft#5473
There was a problem hiding this comment.
🟢 Approval recommended
The focused markup change has matching regression coverage and no blocking issues; tests were not run.
No open issues 🎉
What changed in this PR
Addresses #5473 by making the paginator’s page status a polite live region for screen-reader announcements.
Changes:
- Adds live-region attributes for default and custom pagination text.
- Adds a page-navigation regression test and updates four snapshots.
| File | Description |
|---|---|
| tests/Core/Components/Paginator/FluentPaginatorTests.razor | Tests live-region attributes and updated page text. |
| tests/Core/Components/Paginator/FluentPaginatorTests.FluentPaginator_SetItemsPerPage.verified.razor.html | Updates items-per-page snapshot. |
| tests/Core/Components/Paginator/FluentPaginatorTests.FluentPaginator_Renders_WithDefaultState.verified.razor.html | Updates default-state snapshot. |
| tests/Core/Components/Paginator/FluentPaginatorTests.FluentPaginator_Renders_CustomSummaryTemplate.verified.razor.html | Updates custom-summary snapshot. |
| tests/Core/Components/Paginator/FluentPaginatorTests.FluentPaginator_Renders_CustomPaginationTextTemplate.verified.razor.html | Updates custom-pagination snapshot. |
| src/Core/Components/Pagination/FluentPaginator.razor | Adds role="status" and aria-live="polite". |
Review effort: Balanced
|
Could you please provide a short video showing the issue before the code change, and then the expected behavior after the fix? This will make it easier to clearly see and validate the improvement. |
When several paginators share the same PaginationState (e.g. above and below a grid), every pagination text was a live region, so the new page was announced once per paginator. The status is now announced in a hidden live region of the paginator whose buttons changed the page.
…or last page The first / previous / next / last buttons were disabled when the page couldn't change, so the focused button lost the focus when reaching the first or last page, and screen readers announced the page title. They're now disabled but focusable at the first and last pages.
|
Here is the requested video, recorded with Narrator (sound on) on Before (dev): the page changes, but the new page isn't announced. 5475-before.mp4After (this PR): "Page 2 of 3", then "Page 3 of 3" is announced once. At the last page, the focus stays on the button, so the page title is no longer announced. 5475-after.mp4Recording this showed two issues in the first version of the PR, both fixed now: the page was announced twice on pages with two paginators sharing the same state, and the focus was lost when the button became disabled at the last page. The PR description is updated. |
|
We've added a new requirement regarding PRs
|
Checked |
Pull Request
📖 Description
When the user navigates with the first / previous / next / last buttons, the new page ("Page 2 of 2") is now announced to screen readers.
Changes
FluentPaginatorrenders a visually hidden polite live region (role="status" aria-live="polite"), like the DataGrid sort announcement, with the page status ("Page 2 of 2").PaginationState(e.g. above and below the grid, as inDataGrid/GettingStarted): making each pagination text a live region would announce the new page once per paginator.PaginationStatekeeps the paginator that changed the page (internal), and the other paginators keep an empty live region.DisabledFocusable) instead of disabled: when "Next" reached the last page, the focused button was disabled, the focus moved to the document and screen readers announced the page title before the page status.Disabledon the paginator still disables all the buttons.PaginationTextTemplate) is unchanged.🎫 Issues
👩💻 Reviewer Notes
The live region is visually hidden with the same CSS as the DataGrid sort status. The first / previous and next / last buttons are now
DisabledFocusableat the first and last pages, so the focus isn't lost.📑 Test Plan
Unit tests
Added:
FluentPaginator_PageStatus_IsAnnouncedByThePaginatorUsedFluentPaginator_PageStatus_MovesToTheLastPaginatorUsedFluentPaginator_NextButton_OnLastPage_DoesNotChangePageUpdated
FluentPaginator_FirstPageButtons_DisabledWhenOnFirstPageandFluentPaginator_LastPageButtons_DisabledWhenOnLastPagefordisabled-focusable.The
FluentPaginatorsnapshots are updated with the (empty) live region anddisabled-focusable.tests/Coresuite on this branch: 4906 tests, 0 failed (at7de39e0ea).Manual test
Demo,
DataGrid/GettingStarted(two paginators sharing the same state): "Next" on the bottom paginator fills only its live region ("Page 2 of 3"), then "Next" on the top paginator fills only the top one ("Page 3 of 3") and clears the bottom one.Other checks
✅ Checklist
General
AI contribution declaration
AI assistance is allowed; fully AI-generated or autonomous pull requests without meaningful human review are not accepted. See the AI contribution policy.
Component-specific
⏭ Next Steps
None.