Skip to content

Fix RichTextBox flooding AT channel with entire document on focus#14675

Open
trypsynth wants to merge 1 commit into
dotnet:mainfrom
trypsynth:fix/richtextbox-focus-accessibility-flooding
Open

Fix RichTextBox flooding AT channel with entire document on focus#14675
trypsynth wants to merge 1 commit into
dotnet:mainfrom
trypsynth:fix/richtextbox-focus-accessibility-flooding

Conversation

@trypsynth

@trypsynth trypsynth commented Jun 25, 2026

Copy link
Copy Markdown

Fixes #14671

Proposed changes

Removes the explicit UIA automation notification from OnGotFocus that was sending the full Text of the control to assistive technology on every focus event. For large documents this caused NVDA and JAWS to freeze, and produced a double-announcement (the native MSAA focus event already reads the current line correctly). The pass-through override is kept to satisfy the shipped public API surface.

Customer Impact

Any rich text box with a lot of content in it risks freezing user's assistive technologies.

Regression?

  • No

Risk

  • None

Test methodology

Created a basic winforms app, created a RichTextBox inside it, gave it 6 lines, tested without my custom assembly and with, my custom version fixes the bug.

Accessibility testing

Tested with NVDA on Windows 11 24H2.

Test environment(s)

.NET SDK:
Version: 10.0.202
Commit: 1e7d5a8ae3
Workload version: 10.0.200-manifests.f96d7f23
MSBuild version: 18.3.3+1e7d5a8ae

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.202\

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
Version: 10.0.6
Architecture: x64
Commit: 47fb725acf

.NET SDKs installed:
10.0.202 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 10.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 10.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 10.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
None

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

Microsoft Reviewers: Open in CodeFlow

Removes the explicit UIA automation notification from OnGotFocus that
was sending the full Text of the control to assistive technology on
every focus event. For large documents this caused NVDA and JAWS to
freeze, and produced a double-announcement (the native MSAA focus event
already reads the current line correctly). The pass-through override is
kept to satisfy the shipped public API surface.

Closes dotnet#14671

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.

Pull request overview

This PR addresses an accessibility/performance issue in RichTextBox where focusing the control could flood assistive technology with the entire document text via a UIA automation notification, leading to freezes (notably NVDA/JAWS) and duplicate announcements.

Changes:

  • Removes the UIA automation notification emission from RichTextBox.OnGotFocus, leaving a pass-through override to preserve the existing API surface.
  • Updates the unit test to assert that focusing no longer triggers InternalRaiseAutomationNotification.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/System.Windows.Forms/System/Windows/Forms/Controls/RichTextBox/RichTextBox.cs Removes focus-time UIA notification behavior while keeping an override that delegates to base.
src/test/unit/System.Windows.Forms/System/Windows/Forms/RichTextBoxTests.cs Updates/renames the focus test to verify no automation notification is raised on focus.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

public void RichTextBox_OnGotFocus_DoesNotRaiseAutomationNotification(EventArgs eventArgs)
{
// NVDA and JAWS already announce the focused line via native MSAA on focus; an additional
// UIA automation notification caused the line to be read twice. The correct behaviour is
[WinFormsTheory]
[NewAndDefaultData<EventArgs>]
public void RichTextBox_OnGotFocus_RaisesAutomationNotification_WithText(EventArgs eventArgs)
public void RichTextBox_OnGotFocus_DoesNotRaiseAutomationNotification(EventArgs eventArgs)
Text);
}
}
protected override void OnGotFocus(EventArgs e) => base.OnGotFocus(e);
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.

RichTextBox always sends its entire contents as an accessibility event on focus

2 participants