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
ee396272
Unverified
Commit
ee396272
authored
Jul 30, 2018
by
Jonah Williams
Committed by
GitHub
Jul 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix dropdown button semantics (#19932)
parent
a7595e53
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
19 deletions
+128
-19
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+29
-18
semantics.dart
packages/flutter/lib/src/semantics/semantics.dart
+1
-1
dropdown_test.dart
packages/flutter/test/material/dropdown_test.dart
+98
-0
No files found.
packages/flutter/lib/src/material/dropdown.dart
View file @
ee396272
...
...
@@ -139,6 +139,7 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
//
// When the menu is dismissed we just fade the entire thing out
// in the first 0.25s.
final
MaterialLocalizations
localizations
=
MaterialLocalizations
.
of
(
context
);
final
_DropdownRoute
<
T
>
route
=
widget
.
route
;
final
double
unit
=
0.5
/
(
route
.
items
.
length
+
1.5
);
final
List
<
Widget
>
children
=
<
Widget
>[];
...
...
@@ -175,6 +176,11 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
selectedIndex:
route
.
selectedIndex
,
resize:
_resize
,
),
child:
new
Semantics
(
scopesRoute:
true
,
namesRoute:
true
,
explicitChildNodes:
true
,
label:
localizations
.
popupMenuLabel
,
child:
new
Material
(
type:
MaterialType
.
transparency
,
textStyle:
route
.
style
,
...
...
@@ -192,6 +198,7 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
),
),
),
),
);
}
}
...
...
@@ -627,6 +634,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
style:
_textStyle
.
copyWith
(
color:
Theme
.
of
(
context
).
hintColor
),
child:
new
IgnorePointer
(
child:
widget
.
hint
,
ignoringSemantics:
false
,
),
));
}
...
...
@@ -681,10 +689,13 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
);
}
return
new
GestureDetector
(
return
new
Semantics
(
button:
true
,
child:
new
GestureDetector
(
onTap:
_handleTap
,
behavior:
HitTestBehavior
.
opaque
,
child:
result
),
);
}
}
packages/flutter/lib/src/semantics/semantics.dart
View file @
ee396272
...
...
@@ -365,7 +365,7 @@ class SemanticsData extends Diagnosticable {
scrollExtentMax
,
scrollExtentMin
,
transform
,
customSemanticsActionIds
,
ui
.
hashList
(
customSemanticsActionIds
)
,
);
}
...
...
packages/flutter/test/material/dropdown_test.dart
View file @
ee396272
...
...
@@ -580,4 +580,102 @@ void main() {
semantics
.
dispose
();
});
testWidgets
(
'Dropdown button includes semantics'
,
(
WidgetTester
tester
)
async
{
final
SemanticsHandle
handle
=
tester
.
ensureSemantics
();
const
Key
key
=
const
Key
(
'test'
);
await
tester
.
pumpWidget
(
buildFrame
(
buttonKey:
key
,
value:
null
,
items:
menuItems
,
onChanged:
(
String
_
)
{},
hint:
const
Text
(
'test'
),
));
// By default the hint contributes the label.
expect
(
tester
.
getSemanticsData
(
find
.
byKey
(
key
)),
matchesSemanticsData
(
isButton:
true
,
label:
'test'
,
hasTapAction:
true
,
));
await
tester
.
pumpWidget
(
buildFrame
(
buttonKey:
key
,
value:
'three'
,
items:
menuItems
,
onChanged:
null
,
hint:
const
Text
(
'test'
),
));
// Displays label of select item and is no longer tappable.
expect
(
tester
.
getSemanticsData
(
find
.
byKey
(
key
)),
matchesSemanticsData
(
isButton:
true
,
label:
'three'
,
hasTapAction:
true
,
));
handle
.
dispose
();
});
testWidgets
(
'Dropdown menu includes semantics'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
new
SemanticsTester
(
tester
);
const
Key
key
=
const
Key
(
'test'
);
await
tester
.
pumpWidget
(
buildFrame
(
buttonKey:
key
,
value:
null
,
items:
menuItems
,
));
await
tester
.
tap
(
find
.
byKey
(
key
));
await
tester
.
pumpAndSettle
();
expect
(
semantics
,
hasSemantics
(
new
TestSemantics
.
root
(
children:
<
TestSemantics
>[
new
TestSemantics
.
rootChild
(
children:
<
TestSemantics
>[
new
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
scopesRoute
,
SemanticsFlag
.
namesRoute
,
],
label:
'Popup menu'
,
children:
<
TestSemantics
>[
new
TestSemantics
(
children:
<
TestSemantics
>[
new
TestSemantics
(
children:
<
TestSemantics
>[
new
TestSemantics
(
label:
'one'
,
textDirection:
TextDirection
.
ltr
,
tags:
<
SemanticsTag
>[
const
SemanticsTag
(
'RenderViewport.twoPane'
)],
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
),
new
TestSemantics
(
label:
'two'
,
textDirection:
TextDirection
.
ltr
,
tags:
<
SemanticsTag
>[
const
SemanticsTag
(
'RenderViewport.twoPane'
)],
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
),
new
TestSemantics
(
label:
'three'
,
textDirection:
TextDirection
.
ltr
,
tags:
<
SemanticsTag
>[
const
SemanticsTag
(
'RenderViewport.twoPane'
)],
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
),
new
TestSemantics
(
label:
'four'
,
textDirection:
TextDirection
.
ltr
,
tags:
<
SemanticsTag
>[
const
SemanticsTag
(
'RenderViewport.twoPane'
)],
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
),
],
),
],
),
],
),
],
),
],
),
ignoreId:
true
,
ignoreRect:
true
,
ignoreTransform:
true
));
semantics
.
dispose
();
});
}
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