Skip to content

Conversation

LeafShi1
Copy link
Member

@LeafShi1 LeafShi1 commented Jul 16, 2025

Fixes #13657

Proposed changes

  • Send MSAA focus notification in WmDateChanged of the MonthCalendar so that the MonthCalendar remains in the Focused state when switching dates with the keyboard

Customer Impact

  • NVDA can announce the correct information for the calendar date on which keyboard focus is shifting

Regression?

  • No

Risk

  • Minimal

Screenshots

Before

NVDA cannot announce the correct information for the calendar date

Bug_13657_A11y_WinForms.NETRuntime_CommonControl2_InfoAndRelationships.mp4

After

The calendar date can be announced and the MonthCalendar can be focused with NVDA

NVDA-2024.4.2.mp4

Test methodology

  • Manually

Test environment(s)

  • .net 10.0.0-preview.7.25365.101
Microsoft Reviewers: Open in CodeFlow

@LeafShi1
Copy link
Member Author

Draft the PR because Narrator will announce the calendar date 2 times after the changes

image

Copy link

codecov bot commented Jul 16, 2025

Codecov Report

❌ Patch coverage is 62.50000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.14924%. Comparing base (118a672) to head (fb866e2).
⚠️ Report is 148 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #13707         +/-   ##
===================================================
+ Coverage   76.82947%   77.14924%   +0.31977%     
===================================================
  Files           3257        3276         +19     
  Lines         642592      645134       +2542     
  Branches       47565       47706        +141     
===================================================
+ Hits          493700      497716       +4016     
+ Misses        145232      143733       -1499     
- Partials        3660        3685         +25     
Flag Coverage Δ
Debug 77.14924% <62.50000%> (+0.31977%) ⬆️
integration 18.99657% <62.50000%> (+0.00638%) ⬆️
production 52.01139% <62.50000%> (+0.56972%) ⬆️
test 97.40947% <ø> (-0.00876%) ⬇️
unit 49.45886% <56.25000%> (+0.63815%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@LeafShi1 LeafShi1 removed the draft draft PR label Jul 17, 2025
@LeafShi1 LeafShi1 marked this pull request as ready for review July 17, 2025 09:23
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances accessibility support for the MonthCalendar control by adding automation notifications when the selected date changes. The change ensures that screen readers like NVDA can properly announce date changes when users navigate the calendar with keyboard inputs.

Key changes:

  • Adds automation notification calls in the WmDateChanged method to notify accessibility tools when calendar focus/selection changes
  • Introduces a new app context switch to control this behavior
  • Uses both legacy MSAA events and modern UIA notifications for broader compatibility

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
MonthCalendar.cs Adds automation notification logic in WmDateChanged method with app context switch guard
LocalAppContextSwitches.cs Defines new app context switch for enabling MonthCalendar automation notifications
Comments suppressed due to low confidence (1)

src/System.Windows.Forms.Primitives/src/System/LocalAppContextSwitches/LocalAppContextSwitches.cs:29

  • The switch name contains 'RichTextBox' but should reference 'MonthCalendar' since this switch is for MonthCalendar automation notifications. It should be 'System.Windows.Forms.MonthCalendar.EnableMonthCalendarAutomationNotification'.
    internal const string EnableMonthCalendarAutomationNotificationSwitchName = "System.Windows.Forms.RichTextBox.EnableMonthCalendarAutomationNotification";

@LeafShi1 LeafShi1 force-pushed the Issue_13657_NVDA-announce_MonthCalendar branch from fa2437f to 728b2c6 Compare July 22, 2025 11:04
merriemcgaw
merriemcgaw previously approved these changes Jul 23, 2025
@LeafShi1
Copy link
Member Author

@merriemcgaw Regarding this PR, I need to correct a mistake

Turning on the existing switch AppContextSwitches.NoClientNotifications will turn on MSAA notifications, and NVDA can read calendar date information, but it will also disable UIA notifications, causing Narrator to not focus on MonthCalendar.

I updated the PR, adding MSAA events to MonthCalendar while retaining the original UIA events, so that both tools can read cell content normally, please review again

Epica3055
Epica3055 previously approved these changes Jul 23, 2025
ricardobossan
ricardobossan previously approved these changes Jul 24, 2025
@LeafShi1 LeafShi1 dismissed stale reviews from ricardobossan and Epica3055 via c1aa344 August 7, 2025 02:28
@LeafShi1
Copy link
Member Author

LeafShi1 commented Aug 7, 2025

@merriemcgaw please review this PR again.
After testing, the current fix does not affect the behavior of tools like Narrator and Jaws, and NVDA responds normally to keyboard events.

The only issue currently is that the MonthCalendar control triggers two screen reader announcements when a mouse click occurs: one from the control itself, and one from the manual NotifyWinEvent(AccessibleEvents.Focus) call in WmDateChanged. However, this Focus event cannot be disabled because it is necessary for keyboard navigation and causes NVDA's Focus box to appear.

I can disable NotifyWinEvent(AccessibleEvents.Focus) when executing mouse events, which prevents NVDA from repeating announcements during mouse operations. However, this prevents NVDA's Focus box from appearing.

So, can the mouse issue here be ignored?

@merriemcgaw
Copy link
Member

@KlausLoeffelmann getting this one on your radar for review.

@LeafShi1 LeafShi1 added the waiting-review This item is waiting on review by one or more members of team label Sep 5, 2025
Copy link
Member

@KlausLoeffelmann KlausLoeffelmann left a comment

Choose a reason for hiding this comment

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

Just one little thing, OK otherwise!
Thanks!

@dotnet-policy-service dotnet-policy-service bot added the waiting-author-feedback The team requires more information from the author label Oct 15, 2025
@dotnet-policy-service dotnet-policy-service bot removed the waiting-author-feedback The team requires more information from the author label Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-area-label waiting-review This item is waiting on review by one or more members of team

Projects

None yet

5 participants