Fix accessible Name including control type on ControlExample source expander#798
Open
mmanolova-msft wants to merge 1 commit into
Open
Conversation
…xpander
The shared ControlExample "View Source Code" Expander sets
AutomationProperties.Name to "View Source Code for {HeaderText}". The Fluent
Expander template forwards that Name onto the header ToggleButton (control
type "button"), so any header containing the whole word "Button" (e.g.
"Simple Button", "WPF Accent Button") produces a button whose accessible name
includes its own localized control type. This violates MAS 4.1.2 / the
axe-windows NameExcludesLocalizedControlType rule.
Introduce RemoveControlTypeFromNameConverter, which strips the whole-word
control type (case-insensitive) from the header before it is formatted into
the Name, preserving the unique per-example name added in microsoft#598 while removing
the control-type collision. If stripping would empty the string, the original
value is kept so the Name is never blank.
Fixes AB#3018244, AB#3018295
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The three linked work items report that on some WPF Gallery pages a button's accessible Name includes its own localized control type (MAS 4.1.2 / axe-windows
NameExcludesLocalizedControlType).The failures do not come from the demo controls themselves, but from the shared
ControlExample"View Source Code" Expander. Its Name is set toView Source Code for {HeaderText}, and the Fluent Expander template forwards that Name onto the headerToggleButton(control type button). So any example whose header contains the whole word "Button" — e.g. Simple Button, WPF Accent Button — yields a button named "…Button", which includes its own control type.The unique per-example name was introduced in #598; this PR keeps that uniqueness while removing the control-type collision.
Fix
RemoveControlTypeFromNameConverter— strips the whole-word control type (case-insensitive, matching the axe-windows rule) supplied viaConverterParameter. If stripping would empty the string, the original value is kept so the Name is never blank.ControlExampleExpander'sAutomationProperties.Namebinding withConverterParameter=Button.Effect
Only headers containing the whole word "Button" change:
All other pages (including headerless examples) are unchanged. The demo buttons themselves were already compliant.
Fixes AB#3018244, AB#3018295
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com
Microsoft Reviewers: Open in CodeFlow