Repository navigation
[Calendar] Add button role to year cells - #5582
Denis Voituron (dvoituron) merged 3 commits into
Conversation
The year cells in the years view were focusable and clickable but had no role, so screen readers announced them as a group. Give them the same role logic the month cells already use (button, or none when read-only), update the snapshots that render the year list and add a unit test. Fixes microsoft#5541
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change exposing actionable calendar year cells as buttons to assistive technology.
No open issues 🎉
What changed in this PR
Addresses #5541 by exposing actionable FluentCalendar year cells as buttons to assistive technology, matching the existing month-cell behavior.
Changes:
- Adds a conditional button role to year cells, omitting it for read-only cells.
- Adds parameterized tests for month and year roles with and without
ReadOnly. - Updates four snapshots to reflect the new year-cell roles.
| File | Description |
|---|---|
tests/Core/Components/DateTimes/FluentCalendarTests.razor |
Tests role behavior in month and year views. |
tests/Core/Components/DateTimes/FluentCalendarTests.FluentCalendar_TitleClick-years.verified.razor.html |
Updates year-view role expectations. |
tests/Core/Components/DateTimes/FluentCalendarTests.FluentCalendar_TitleClick-months.verified.razor.html |
Updates nested year-calendar role expectations. |
tests/Core/Components/DateTimes/FluentCalendarTests.FluentCalendar_Minimum_View-years.verified.razor.html |
Updates minimum-date year-cell roles. |
tests/Core/Components/DateTimes/FluentCalendarTests.FluentCalendar_Maximum_View-years.verified.razor.html |
Updates maximum-date year-cell roles. |
src/Core/Components/DateTime/FluentCalendar.razor |
Adds the conditional button role to year cells. |
Review effort: Balanced
Before confirming, we need to verify that NVDA (or another program) can read the text correctly in order to resolve this issue. |
|
@microsoft-github-policy-service agree thank you all!! |
|
yes, sorry about that, i've checked it now with Narrator on Windows 11, on the docs page (DateTime/Calendar, years view):
i didn't build the branch, so this is the released docs page with the attribute added in the browser. Windows UI Automation in a Chromium browser shows the same change: |
|
Thank you. If you'd prefer to check with NVDA, you can download the software here: https://www.nvaccess.org/download/ |
Pull Request
📖 Description
in the years view of
FluentCalendarthe year cells are focusable and clickable, but they have norole, so Narrator announces them as a "group" instead of a button (as reported in the issue). the month cells (just above inFluentCalendar.razor) already getrole="@(ReadOnly || monthProperties.IsReadOnly ? null : "button")", so this gives the year cells the same logic:buttonwhen they can be picked, no role when the calendar is read-only or disabled, or the year itself is disabled / out of range (yearProperties.IsReadOnlycovers those).it's a fix, not a breaking change. only the years view markup changes.
🎫 Issues
Fixes #5541 (approach agreed by vnbaaij in #5541 (comment), targeting
dev)👩💻 Reviewer Notes
FluentCalendar.razor, mirroring the month cell.role="button"on each year cell, nothing else changed in them. in the issue i said 3, the 4th isTitleClick-months, which also renders a nested years calendar.📑 Test Plan
FluentCalendar_MonthAndYearCells_HaveButtonRoleUnlessReadOnly(months + years view, with and withoutReadOnly): every cell hasrole="button"normally, and none has a role when the calendar isReadOnly..verified.razor.htmlsnapshots by hand (Minimum_View-years,Maximum_View-years,TitleClick-years,TitleClick-months).build-core-libworkflow (build, all unit test projects incl. the .NET 11 run, and the 98% coverage check) passed in GitHub Actions on my fork for commit8c568cd: https://github.com/rohitmulani63-ops/fluentui-blazor/actions/runs/41608764260AI-assisted; I reviewed and understand the change.
✅ Checklist
General
Issue discussion declaration
Discuss changes before implementing them to confirm that the problem and proposed approach fit the project. See Discuss before implementing for the process and exceptions.
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
#5544 (Voice Access numbers on the same year cells) might be helped by this too, but i haven't checked it.