Skip to content

[Calendar] Expose selected and disabled day states to assistive technologies - #5614

Merged
Denis Voituron (dvoituron) merged 2 commits into
microsoft:devfrom
jeff377:fix/calendar-aria-states
Nov 9, 2026
Merged

Denis Voituron (dvoituron) merged 2 commits into
microsoft:devfrom
jeff377:fix/calendar-aria-states

Conversation

@jeff377

@jeff377 Jeff (jeff377) commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request

📖 Description

Screen readers did not announce the state of days in FluentCalendar:

This PR changes the day element in FluentCalendar.razor:

  • Selected days, including days in a multi-day selection, get aria-pressed="true".
  • Disabled days keep role="button" and get aria-disabled="true". They still have no tabindex, so keyboard navigation does not change.
  • Read-only calendars and inactive days (outside the current month) are unchanged.

There is no visual change. FluentDatePicker uses the same calendar, so it gets the same fix.

As proposed in the issue, this PR:

  • Uses aria-pressed rather than aria-selected, because aria-selected isn't allowed on role="button". Screen readers announce "pressed" rather than "selected". Announcing "selected" would require a grid / gridcell structure, which is a larger change.
  • Only changes the day view. The month and year views use the same pattern, and can be updated in a follow-up if you'd like.

Type: fix (accessibility), not a breaking change.

🎫 Issues

Fixes #5542
Fixes #5543

The approach was proposed in #5542 (comment) (and linked from #5543), and agreed in the maintainer reply that follows it.

👩‍💻 Reviewer Notes

  • The only component change is two attributes and one condition on the day element in FluentCalendar.razor. The other files are snapshot updates.
  • Smoke test: open the Calendar page in the demo. In the first example, inspect a disabled day (for example, the 3rd) and the selected day in the browser accessibility tree.

Before (dev):

<div part="day" class="day" disabled="" aria-label="November 3" value="2026-11-03">3</div>
<div part="day" class="day" role="button" tabindex="0" today="" selected="" aria-label="November 9" value="2026-11-09">9</div>

After:

<div part="day" class="day" role="button" aria-disabled="true" disabled="" aria-label="November 3" value="2026-11-03">3</div>
<div part="day" class="day" role="button" tabindex="0" aria-pressed="true" today="" selected="" aria-label="November 9" value="2026-11-09">9</div>

In the Chrome accessibility tree, the days change from generic "November 3" and button "November 9" (no states) to button "November 3" (disabled) and button "November 9" (pressed).

📑 Test Plan

  • Updated 9 snapshots in the FluentCalendar and FluentDatePicker tests. I compared each .received file with its .verified file: the only differences are the new role, aria-disabled, and aria-pressed attributes.
  • Added FluentCalendar_SelectMode_Multiple_SelectedDaysArePressed and FluentCalendar_SelectMode_Range_SelectedDaysArePressed: every selected day has aria-pressed="true", other days don't, and the attribute is removed after unselecting a day or resetting a range. Both tests fail without the component change, and also fail if the multi-day branch is removed.
  • Ran the full tests/Core/Components.Tests.csproj suite locally on macOS: all 5261 tests passed.
  • Built Microsoft.FluentUI-v5.slnx with no warnings or errors.
  • Checked the rendered markup and the accessibility tree in the demo (Blazor Server) with Chrome 157 on macOS. Not tested with a real screen reader (Narrator / VoiceOver), or in Edge, Firefox, or Safari.

✅ 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

If you'd like, I can apply the same change to the month and year views in a follow-up PR.

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.

🟡 Changes recommended

The tests do not exercise the new multi-day selection branch, leaving aria-pressed behavior for selected days, deselection, and range resets unverified.

1 open issue
What changed in this PR

This PR exposes selected and disabled day states in FluentCalendar to assistive technologies, addressing #5542 and #5543. FluentDatePicker inherits the same accessibility improvements.

Changes:

  • Adds aria-pressed="true" for selected days, including multi-day selections.
  • Preserves button semantics for disabled days and adds aria-disabled="true", without changing tab order.
  • Updates nine snapshots; read-only calendars, inactive days, and month/year views remain unchanged.
File Description
tests/​Core/​Components/​DateTimes/​FluentDatePickerTests.FluentDatePicker_Default.verified.razor.html Updates embedded calendar selected and disabled states.
tests/​Core/​Components/​DateTimes/​FluentCalendarTests.FluentCalendar_WeekDaysTitle.verified.razor.html Adds selected-day pressed state.
tests/​Core/​Components/​DateTimes/​FluentCalendarTests.FluentCalendar_WeekDays_French.verified.razor.html Adds pressed state in the French snapshot.
tests/​Core/​Components/​DateTimes/​FluentCalendarTests.FluentCalendar_Title.verified.razor.html Updates selected-day markup.
tests/​Core/​Components/​DateTimes/​FluentCalendarTests.FluentCalendar_Title_ByCulture-fa-IR.verified.razor.html Adds pressed state in the Persian-calendar snapshot.
tests/​Core/​Components/​DateTimes/​FluentCalendarTests.FluentCalendar_Title_ByCulture-en-US.verified.razor.html Adds pressed state in the US-English snapshot.
tests/​Core/​Components/​DateTimes/​FluentCalendarTests.FluentCalendar_MinMax.verified.razor.html Updates disabled boundary dates and selected-day state.
tests/​Core/​Components/​DateTimes/​FluentCalendarTests.FluentCalendar_Minimum_View-days.verified.razor.html Adds pressed state in the minimum-date snapshot.
tests/​Core/​Components/​DateTimes/​FluentCalendarTests.FluentCalendar_Default.verified.razor.html Updates default selected and disabled day markup.
src/​Core/​Components/​DateTime/​FluentCalendar.razor Exposes day selection and disabled states through ARIA attributes.

Review effort: Balanced

@dvoituron
Denis Voituron (dvoituron) merged commit 9cdc610 into microsoft:dev Nov 9, 2026
9 checks passed
@jeff377
Jeff (jeff377) deleted the fix/calendar-aria-states branch November 9, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants