Skip to content

[Calendar] Add button role to year cells - #5582

Merged
Denis Voituron (dvoituron) merged 3 commits into
microsoft:devfrom
rohitmulani63-ops:calendar-year-button-role
Nov 6, 2026
Merged

Denis Voituron (dvoituron) merged 3 commits into
microsoft:devfrom
rohitmulani63-ops:calendar-year-button-role

Conversation

@rohitmulani63-ops

@rohitmulani63-ops Rohit Mulani (rohitmulani63-ops) commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request

📖 Description

in the years view of FluentCalendar the year cells are focusable and clickable, but they have no role, so Narrator announces them as a "group" instead of a button (as reported in the issue). the month cells (just above in FluentCalendar.razor) already get role="@(ReadOnly || monthProperties.IsReadOnly ? null : "button")", so this gives the year cells the same logic: button when they can be picked, no role when the calendar is read-only or disabled, or the year itself is disabled / out of range (yearProperties.IsReadOnly covers 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

  • one line in FluentCalendar.razor, mirroring the month cell.
  • the 4 snapshots that render the year list now have role="button" on each year cell, nothing else changed in them. in the issue i said 3, the 4th is TitleClick-months, which also renders a nested years calendar.
  • checked with Narrator since (see my comment in the thread).

📑 Test Plan

  • added FluentCalendar_MonthAndYearCells_HaveButtonRoleUnlessReadOnly (months + years view, with and without ReadOnly): every cell has role="button" normally, and none has a role when the calendar is ReadOnly.
  • updated the 4 affected .verified.razor.html snapshots by hand (Minimum_View-years, Maximum_View-years, TitleClick-years, TitleClick-months).
  • i didn't build or run it locally. the build-core-lib workflow (build, all unit test projects incl. the .NET 11 run, and the 98% coverage check) passed in GitHub Actions on my fork for commit 8c568cd: https://github.com/rohitmulani63-ops/fluentui-blazor/actions/runs/41608764260
  • Narrator on Windows 11, released docs page: a year cell reads "group"; with role="button" added in the browser it reads "2022, button" (see my comment). NVDA not tried.

AI-assisted; I reviewed and understand the change.

✅ Checklist

General

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

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.

  • I have discussed this change in an issue and received maintainer agreement before implementation, or a documented exception applies.

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.

  • I have read and followed the AI contribution policy.
  • I have personally reviewed and understood all changes, tested them, and take responsibility for this contribution.

Component-specific

  • I have added a new component
  • I have added Unit Tests for my new component
  • I have modified an existing component
  • I have validated the Unit Tests for an existing component

⏭ Next Steps

#5544 (Voice Access numbers on the same year cells) might be helped by this too, but i haven't checked it.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@dvoituron

Copy link
Copy Markdown
Collaborator

i couldn't check it with a screen reader myself, so a quick Narrator/NVDA pass on a year cell would be great: open a calendar, click the title twice to get to the years view, tab to a year, it should be announced as a button.

Before confirming, we need to verify that NVDA (or another program) can read the text correctly in order to resolve this issue.

@rohitmulani63-ops

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

thank you all!!

@rohitmulani63-ops

Copy link
Copy Markdown
Contributor Author

yes, sorry about that, i've checked it now with Narrator on Windows 11, on the docs page (DateTime/Calendar, years view):

  • current docs, in Edge: tabbing to a year, Narrator says "group"
  • in Chrome, with role="button" added to the year cells from the browser console (the markup this PR renders, see the updated snapshots): it says "2022, button"

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: ControlType.Group before, ControlType.Button after. i haven't tried NVDA.

@dvoituron

Copy link
Copy Markdown
Collaborator

Thank you. If you'd prefer to check with NVDA, you can download the software here: https://www.nvaccess.org/download/

@dvoituron
Denis Voituron (dvoituron) merged commit a62729b into microsoft:dev Nov 6, 2026
5 checks passed
This was referenced Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FluentCalendar]: Screen reader announces an incorrect "Group" role instead of "Button" for year controls in the Calendar

3 participants