Skip to content

Commit b3ae87f

Browse files
committed
fix: set StaysOpenOnClick on screen-reader TextBlock
1 parent 5994df0 commit b3ae87f

File tree

1 file changed

+38
-30
lines changed

1 file changed

+38
-30
lines changed

src/Wpf.Ui/Controls/Menu/MenuItem.xaml

+38-30
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,18 @@
7474
ContentSource="Header"
7575
RecognizesAccessKey="True"
7676
TextElement.Foreground="{TemplateBinding Foreground}" />
77-
<!-- TextBlock added so that screen readers don't try to read Icon -->
78-
<TextBlock Grid.Column="0"
77+
<!-- TextBlock added so that screen readers don't try to read Icon -->
78+
<TextBlock
79+
Grid.Column="0"
7980
Grid.ColumnSpan="3"
8081
Width="{TemplateBinding Width}"
8182
Height="{TemplateBinding Height}"
8283
Margin="-10"
84+
Background="Black"
8385
FontSize="1"
86+
IsHitTestVisible="False"
8487
Opacity="0"
85-
Text="{TemplateBinding AutomationProperties.Name}"
86-
Background="Black"/>
88+
Text="{TemplateBinding AutomationProperties.Name}" />
8789
</Grid>
8890

8991
<Popup
@@ -191,16 +193,18 @@
191193
ContentSource="Header"
192194
RecognizesAccessKey="True"
193195
TextElement.Foreground="{TemplateBinding Foreground}" />
194-
<!-- TextBlock added so that screen readers don't try to read Icon -->
195-
<TextBlock Grid.Column="0"
196-
Grid.ColumnSpan="3"
197-
Width="{TemplateBinding Width}"
198-
Height="{TemplateBinding Height}"
199-
Margin="-10"
200-
FontSize="1"
201-
Opacity="0"
202-
Text="{TemplateBinding AutomationProperties.Name}"
203-
Background="Black"/>
196+
<!-- TextBlock added so that screen readers don't try to read Icon -->
197+
<TextBlock
198+
Grid.Column="0"
199+
Grid.ColumnSpan="2"
200+
Width="{TemplateBinding Width}"
201+
Height="{TemplateBinding Height}"
202+
Margin="-10"
203+
Background="Black"
204+
FontSize="1"
205+
IsHitTestVisible="False"
206+
Opacity="0"
207+
Text="{TemplateBinding AutomationProperties.Name}" />
204208
</Grid>
205209
</Border>
206210
<ControlTemplate.Triggers>
@@ -284,17 +288,19 @@
284288
FontSize="11"
285289
Foreground="{DynamicResource TextFillColorDisabledBrush}"
286290
Text="{TemplateBinding InputGestureText}" />
287-
288-
<!-- TextBlock added so that screen readers don't try to read Icon -->
289-
<TextBlock Grid.Column="0"
290-
Grid.ColumnSpan="5"
291-
Width="{TemplateBinding Width}"
292-
Height="{TemplateBinding Height}"
293-
Margin="-10"
294-
FontSize="1"
295-
Opacity="0"
296-
Text="{TemplateBinding AutomationProperties.Name}"
297-
Background="Black"/>
291+
292+
<!-- TextBlock added so that screen readers don't try to read Icon -->
293+
<TextBlock
294+
Grid.Column="0"
295+
Grid.ColumnSpan="4"
296+
Width="{TemplateBinding Width}"
297+
Height="{TemplateBinding Height}"
298+
Margin="-10"
299+
Background="Black"
300+
FontSize="1"
301+
IsHitTestVisible="False"
302+
Opacity="0"
303+
Text="{TemplateBinding AutomationProperties.Name}" />
298304
</Grid>
299305
</Border>
300306
<ControlTemplate.Triggers>
@@ -365,17 +371,19 @@
365371
FontSize="{TemplateBinding FontSize}"
366372
Symbol="ChevronRight20" />
367373
</Grid>
368-
369-
<!-- Fix double narration from mousing over the button and then the associated text -->
370-
<TextBlock Grid.Column="0"
374+
375+
<!-- Fix double narration from mousing over the button and then the associated text -->
376+
<TextBlock
377+
Grid.Column="0"
371378
Grid.ColumnSpan="3"
372379
Width="{TemplateBinding Width}"
373380
Height="{TemplateBinding Height}"
374381
Margin="-10"
382+
Background="Black"
375383
FontSize="1"
384+
IsHitTestVisible="False"
376385
Opacity="0"
377-
Text="{TemplateBinding AutomationProperties.Name}"
378-
Background="Black"/>
386+
Text="{TemplateBinding AutomationProperties.Name}" />
379387
</Grid>
380388
</Border>
381389

0 commit comments

Comments
 (0)