Skip to content

Commit dee71cd

Browse files
Fix null Name on empty page header description (MAS 4.1.2) (#781)
The PageHeader description Label is a focusable tab stop, but its visibility used NullToVisibilityConverter, which only collapses on null - not on an empty string. Pages whose description is "" (Label, TextBox, TextBlock, RichTextEdit, PasswordBox and many others) therefore rendered an empty, focusable element with a null UI Automation Name, flagged by Accessibility Insights as "The Name property of a focusable element must not be null" (MAS 4.1.2 - Name, Role, Value). - Switch the description Label visibility to EmptyToVisibilityConverter so it collapses on null, empty, or whitespace, removing the empty focusable element entirely. - Add AutomationProperties.Name bound to Description so the description has a meaningful Name when it is visible. - Remove the now-unused NullToVisibilityConverter resource declaration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0238f8a commit dee71cd

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Sample Applications/WPFGallery/Controls/PageHeader.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:controls="clr-namespace:WPFGallery.Controls"
55
xmlns:helpers="clr-namespace:WPFGallery.Helpers">
66

7-
<helpers:NullToVisibilityConverter x:Key="NullToVisibilityConverter"/>
7+
<helpers:EmptyToVisibilityConverter x:Key="EmptyToVisibilityConverter"/>
88

99
<Style TargetType="{x:Type controls:PageHeader}">
1010
<Setter Property="Focusable" Value="False"/>
@@ -25,10 +25,11 @@
2525
</Label>
2626

2727
<Label
28+
AutomationProperties.Name="{Binding Description, RelativeSource={RelativeSource Mode=TemplatedParent}}"
2829
AutomationProperties.HeadingLevel="Level2"
2930
KeyboardNavigation.IsTabStop="True"
3031
KeyboardNavigation.TabIndex="1"
31-
Visibility="{TemplateBinding Description, Converter={StaticResource NullToVisibilityConverter}}"
32+
Visibility="{TemplateBinding Description, Converter={StaticResource EmptyToVisibilityConverter}}"
3233
Focusable="True">
3334
<TextBlock
3435
x:Name="DescriptionTextBlock"

0 commit comments

Comments
 (0)