Skip to content

Use a TextBlock's AutomationProperties.Name as its automation name - #22605

Open
hazeliscoding wants to merge 2 commits into
AvaloniaUI:mainfrom
hazeliscoding:fix/textblock-automation-name
Open

hazeliscoding wants to merge 2 commits into
AvaloniaUI:mainfrom
hazeliscoding:fix/textblock-automation-name

Conversation

@hazeliscoding

Copy link
Copy Markdown

What does the pull request do?

TextBlockAutomationPeer used a TextBlock's text as its automation name even when AutomationProperties.Name was set, and raised a name change on every Text change. It now reads AutomationProperties.Name and then LabeledBy first, like ContentControlAutomationPeer and the page peers, and falls back to the text. A Text change raises a name change only when the text is the name. SelectableTextBlock uses the same peer, so it's fixed too.

What is the current behavior?

AutomationProperties.Name on a TextBlock has no effect. A TextBlock with AutomationProperties.LiveSetting is announced on every text change, even when an explicit name was set to stop that.

How was the solution implemented (if it's not obvious)?

The first commit adds the tests. Two fail without the fix, and two check that the text is still the name, and still raises name changes, when no explicit name is set.

Fixed issues

Fixes #22584

AutomationProperties.Name set on a TextBlock is ignored, and every Text
change raises a name change even when an explicit name is set.
TextBlockAutomationPeer now reads the explicit name first, like the
other peers, and raises a name change for a Text change only when the
text is the name.
@MrJul MrJul added enhancement area-accessibility backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Oct 26, 2026
@github-actions

Copy link
Copy Markdown

NuGet packages

The packages for this pull request have been published (workflow run):

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-accessibility backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextBlock ignores AutomationProperties.Name, and a live TextBlock is announced on every text change

2 participants