Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
a4de77a2
Unverified
Commit
a4de77a2
authored
May 26, 2023
by
Qun Cheng
Committed by
GitHub
May 26, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove button announcement for `MenuItemButton` and `SubmenuButton` (#127620)
parent
20637188
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
1 deletion
+95
-1
button_style_button.dart
packages/flutter/lib/src/material/button_style_button.dart
+11
-1
menu_anchor.dart
packages/flutter/lib/src/material/menu_anchor.dart
+2
-0
text_button.dart
packages/flutter/lib/src/material/text_button.dart
+1
-0
menu_anchor_test.dart
packages/flutter/test/material/menu_anchor_test.dart
+81
-0
No files found.
packages/flutter/lib/src/material/button_style_button.dart
View file @
a4de77a2
...
...
@@ -42,6 +42,7 @@ abstract class ButtonStyleButton extends StatefulWidget {
required
this
.
autofocus
,
required
this
.
clipBehavior
,
this
.
statesController
,
this
.
isSemanticButton
=
true
,
required
this
.
child
,
});
...
...
@@ -100,6 +101,15 @@ abstract class ButtonStyleButton extends StatefulWidget {
/// {@macro flutter.material.inkwell.statesController}
final
MaterialStatesController
?
statesController
;
/// Determine whether this subtree represents a button.
///
/// If this is null, the screen reader will not announce "button" when this
/// is focused. This is useful for [MenuItemButton] and [SubmenuButton] when we
/// traverse the menu system.
///
/// Defaults to true.
final
bool
?
isSemanticButton
;
/// Typically the button's label.
///
/// {@macro flutter.widgets.ProxyWidget.child}
...
...
@@ -425,7 +435,7 @@ class _ButtonStyleState extends State<ButtonStyleButton> with TickerProviderStat
return
Semantics
(
container:
true
,
button:
true
,
button:
widget
.
isSemanticButton
,
enabled:
widget
.
enabled
,
child:
_InputPadding
(
minSize:
minSize
,
...
...
packages/flutter/lib/src/material/menu_anchor.dart
View file @
a4de77a2
...
...
@@ -1062,6 +1062,7 @@ class _MenuItemButtonState extends State<MenuItemButton> {
style:
mergedStyle
,
statesController:
widget
.
statesController
,
clipBehavior:
widget
.
clipBehavior
,
isSemanticButton:
null
,
child:
_MenuItemLabel
(
leadingIcon:
widget
.
leadingIcon
,
shortcut:
widget
.
shortcut
,
...
...
@@ -1903,6 +1904,7 @@ class _SubmenuButtonState extends State<SubmenuButton> {
focusNode:
_buttonFocusNode
,
onHover:
_enabled
?
(
bool
hovering
)
=>
handleHover
(
hovering
,
context
)
:
null
,
onPressed:
_enabled
?
()
=>
toggleShowMenu
(
context
)
:
null
,
isSemanticButton:
null
,
child:
_MenuItemLabel
(
leadingIcon:
widget
.
leadingIcon
,
trailingIcon:
widget
.
trailingIcon
,
...
...
packages/flutter/lib/src/material/text_button.dart
View file @
a4de77a2
...
...
@@ -87,6 +87,7 @@ class TextButton extends ButtonStyleButton {
super
.
autofocus
=
false
,
super
.
clipBehavior
=
Clip
.
none
,
super
.
statesController
,
super
.
isSemanticButton
,
required
Widget
super
.
child
,
});
...
...
packages/flutter/test/material/menu_anchor_test.dart
View file @
a4de77a2
...
...
@@ -10,6 +10,7 @@ import 'package:flutter/services.dart';
import
'package:flutter_test/flutter_test.dart'
;
import
'../rendering/mock_canvas.dart'
;
import
'../widgets/semantics_tester.dart'
;
void
main
(
)
{
late
MenuController
controller
;
...
...
@@ -3040,6 +3041,86 @@ void main() {
expect
(
radioValue
,
1
);
});
});
group
(
'Semantics'
,
()
{
testWidgets
(
'MenuItemButton is not a semantic button'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
MenuItemButton
(
style:
MenuItemButton
.
styleFrom
(
fixedSize:
const
Size
(
88.0
,
36.0
)),
onPressed:
()
{
},
child:
const
Text
(
'ABC'
),
),
),
),
);
// The flags should not have SemanticsFlag.isButton
expect
(
semantics
,
hasSemantics
(
TestSemantics
.
root
(
children:
<
TestSemantics
>[
TestSemantics
.
rootChild
(
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
],
label:
'ABC'
,
rect:
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
88.0
,
48.0
),
transform:
Matrix4
.
translationValues
(
356.0
,
276.0
,
0.0
),
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
hasEnabledState
,
SemanticsFlag
.
isEnabled
,
SemanticsFlag
.
isFocusable
,
],
textDirection:
TextDirection
.
ltr
,
),
],
),
ignoreId:
true
,
));
semantics
.
dispose
();
});
testWidgets
(
'SubMenuButton is not a semantic button'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
SubmenuButton
(
onHover:
(
bool
value
)
{},
style:
SubmenuButton
.
styleFrom
(
fixedSize:
const
Size
(
88.0
,
36.0
)),
menuChildren:
const
<
Widget
>[],
child:
const
Text
(
'ABC'
),
),
),
),
);
// The flags should not have SemanticsFlag.isButton
expect
(
semantics
,
hasSemantics
(
TestSemantics
.
root
(
children:
<
TestSemantics
>[
TestSemantics
.
rootChild
(
label:
'ABC'
,
rect:
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
88.0
,
48.0
),
transform:
Matrix4
.
translationValues
(
356.0
,
276.0
,
0.0
),
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
hasEnabledState
,
],
textDirection:
TextDirection
.
ltr
,
),
],
),
ignoreId:
true
,
));
semantics
.
dispose
();
});
});
}
List
<
Widget
>
createTestMenus
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment