Commit f6aad629 authored by Daco Harkes's avatar Daco Harkes
Browse files

Merge branch 'main' into native-assets-linux

No related merge requests found
Showing with 30 additions and 2 deletions
+30 -2
51a402860f5b537720b72af69a98ad85209671e7
77965cabbaf96e62df3b78d500629b7f23b877ec
2TJNsB32jPioIfFaoLtDUK2JsGct6o1oo_fISGZ_vWgC
3_Lh8otTpmVuf-Zwb5yQy61cqmV-4g7xjO1wsANaeC0C
......@@ -74,6 +74,11 @@ class _DropdownMenuExampleState extends State<DropdownMenuExample> {
DropdownMenu<ColorLabel>(
initialSelection: ColorLabel.green,
controller: colorController,
// requestFocusOnTap is enabled/disabled by platforms when it is null.
// On mobile platforms, this is false by default. Setting this to true will
// trigger focus request on the text field and virtual keyboard will appear
// afterward. On desktop platforms however, this defaults to true.
requestFocusOnTap: true,
label: const Text('Color'),
onSelected: (ColorLabel? color) {
setState(() {
......@@ -97,6 +102,7 @@ class _DropdownMenuExampleState extends State<DropdownMenuExample> {
DropdownMenu<IconLabel>(
controller: iconController,
enableFilter: true,
requestFocusOnTap: true,
leadingIcon: const Icon(Icons.search),
label: const Text('Icon'),
inputDecorationTheme: const InputDecorationTheme(
......
......@@ -52,4 +52,26 @@ void main() {
expect(find.text('You selected a Blue Smile'), findsOneWidget);
});
testWidgets('DropdownMenu has focus when tapping on the text field', (WidgetTester tester) async {
await tester.pumpWidget(
const example.DropdownMenuExample(),
);
// Make sure the dropdown menus are there.
final Finder colorMenu = find.byType(DropdownMenu<example.ColorLabel>);
final Finder iconMenu = find.byType(DropdownMenu<example.IconLabel>);
expect(colorMenu, findsOneWidget);
expect(iconMenu, findsOneWidget);
// Tap on the color menu and make sure it is focused.
await tester.tap(colorMenu);
await tester.pumpAndSettle();
expect(FocusScope.of(tester.element(colorMenu)).hasFocus, isTrue);
// Tap on the icon menu and make sure it is focused.
await tester.tap(iconMenu);
await tester.pumpAndSettle();
expect(FocusScope.of(tester.element(iconMenu)).hasFocus, isTrue);
});
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment