Skip to content

Commit ca2cdfb

Browse files
Fix a focus traversal issue with search fields (#9166)
* Fix a focus traversal issue with search fields * rnotes * merge
1 parent 09e1278 commit ca2cdfb

2 files changed

Lines changed: 63 additions & 60 deletions

File tree

packages/devtools_app/lib/src/shared/ui/search.dart

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,67 +1010,69 @@ class StatelessSearchField<T extends SearchableDataMixin>
10101010
controller.searchFieldFocusNode?.requestFocus();
10111011
}
10121012

1013-
final searchField = TextField(
1014-
key: searchFieldKey,
1015-
autofocus: true,
1016-
enabled: searchFieldEnabled,
1017-
focusNode: controller.searchFieldFocusNode,
1018-
controller: controller.searchTextFieldController,
1019-
style: textStyle,
1020-
maxLines: _maxLines,
1021-
onChanged: onChanged,
1022-
onEditingComplete: () {
1023-
controller.searchFieldFocusNode?.requestFocus();
1024-
},
1025-
// Guarantee that the TextField on all platforms renders in the same
1026-
// color for border, label text, and cursor. Primarly, so golden screen
1027-
// snapshots will compare with the exact color.
1028-
// Guarantee that the TextField on all platforms renders in the same
1029-
// color for border, label text, and cursor. Primarly, so golden screen
1030-
// snapshots will compare with the exact color.
1031-
decoration:
1032-
decoration ??
1033-
InputDecoration(
1034-
constraints: BoxConstraints(
1035-
minHeight: searchFieldHeight ?? defaultTextFieldHeight,
1036-
),
1037-
contentPadding: const EdgeInsets.symmetric(
1038-
horizontal: densePadding,
1039-
),
1040-
border: const OutlineInputBorder(),
1041-
hintText: 'Search',
1042-
hintStyle: theme.subtleTextStyle,
1043-
labelText: label,
1044-
labelStyle: theme.subtleTextStyle,
1045-
prefixIcon: Icon(Icons.search, size: defaultIconSize),
1046-
prefix: prefix != null
1047-
? Row(
1048-
mainAxisSize: MainAxisSize.min,
1049-
mainAxisAlignment: MainAxisAlignment.end,
1050-
children: <Widget>[
1051-
prefix!,
1052-
SizedBox(
1053-
height: inputDecorationElementHeight,
1054-
width: defaultIconSize,
1055-
child: Transform.rotate(
1056-
angle: degToRad(90),
1057-
child: PaddedDivider.vertical(),
1013+
final searchField = FocusTraversalGroup(
1014+
child: TextField(
1015+
key: searchFieldKey,
1016+
autofocus: true,
1017+
enabled: searchFieldEnabled,
1018+
focusNode: controller.searchFieldFocusNode,
1019+
controller: controller.searchTextFieldController,
1020+
style: textStyle,
1021+
maxLines: _maxLines,
1022+
onChanged: onChanged,
1023+
onEditingComplete: () {
1024+
controller.searchFieldFocusNode?.requestFocus();
1025+
},
1026+
// Guarantee that the TextField on all platforms renders in the same
1027+
// color for border, label text, and cursor. Primarly, so golden screen
1028+
// snapshots will compare with the exact color.
1029+
// Guarantee that the TextField on all platforms renders in the same
1030+
// color for border, label text, and cursor. Primarly, so golden screen
1031+
// snapshots will compare with the exact color.
1032+
decoration:
1033+
decoration ??
1034+
InputDecoration(
1035+
constraints: BoxConstraints(
1036+
minHeight: searchFieldHeight ?? defaultTextFieldHeight,
1037+
),
1038+
contentPadding: const EdgeInsets.symmetric(
1039+
horizontal: densePadding,
1040+
),
1041+
border: const OutlineInputBorder(),
1042+
hintText: 'Search',
1043+
hintStyle: theme.subtleTextStyle,
1044+
labelText: label,
1045+
labelStyle: theme.subtleTextStyle,
1046+
prefixIcon: Icon(Icons.search, size: defaultIconSize),
1047+
prefix: prefix != null
1048+
? Row(
1049+
mainAxisSize: MainAxisSize.min,
1050+
mainAxisAlignment: MainAxisAlignment.end,
1051+
children: <Widget>[
1052+
prefix!,
1053+
SizedBox(
1054+
height: inputDecorationElementHeight,
1055+
width: defaultIconSize,
1056+
child: Transform.rotate(
1057+
angle: degToRad(90),
1058+
child: PaddedDivider.vertical(),
1059+
),
10581060
),
1059-
),
1060-
],
1061-
)
1062-
: null,
1063-
suffix:
1064-
suffix ??
1065-
_SearchFieldSuffix(
1066-
controller: controller,
1067-
supportsNavigation: supportsNavigation,
1068-
onClose: () {
1069-
onClose?.call();
1070-
onChanged('');
1071-
},
1072-
),
1073-
),
1061+
],
1062+
)
1063+
: null,
1064+
suffix:
1065+
suffix ??
1066+
_SearchFieldSuffix(
1067+
controller: controller,
1068+
supportsNavigation: supportsNavigation,
1069+
onClose: () {
1070+
onClose?.call();
1071+
onChanged('');
1072+
},
1073+
),
1074+
),
1075+
),
10741076
);
10751077

10761078
if (shouldRequestFocus) {

packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ To learn more about DevTools, check out the
1818
- Prevent web apps from remaining paused after triggering a hot-restart from
1919
DevTools. - [#9125](https://github.com/flutter/devtools/pull/9125)
2020
- Dismiss stale banner messages when the connected app state changes. - [#9148](https://github.com/flutter/devtools/pull/9148)
21+
- Fix a focus traversal issue with search fields. [#9166](https://github.com/flutter/devtools/pull/9166)
2122

2223
## Inspector updates
2324

0 commit comments

Comments
 (0)