Skip to content

Commit

Permalink
search as we type, and prev/next with shift+enter/enter
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderDake committed Nov 7, 2023
1 parent 0e3539e commit 8b514b8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/devtools_app/lib/src/shared/ui/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,22 @@ mixin SearchControllerMixin<T extends SearchableDataMixin> {
_searchFieldFocusNode?.dispose();
_searchTextFieldController = SearchTextEditingController()
..text = _searchNotifier.value;
_searchFieldFocusNode = FocusNode(debugLabel: 'search-field');
_searchFieldFocusNode = FocusNode(
debugLabel: 'search-field',
onKey: (FocusNode node, RawKeyEvent event) {
if (event.logicalKey.keyLabel == 'Enter') {
if (event is RawKeyDownEvent) {
if (event.isShiftPressed) {
previousMatch();
} else {
nextMatch();
}
return KeyEventResult.handled;
}
}
return KeyEventResult.ignored;
},
);
}

@mustCallSuper
Expand Down Expand Up @@ -1041,6 +1056,7 @@ class StatelessSearchField<T extends SearchableDataMixin>
onChanged: (value) {
onChanged?.call(value);
controller.search = value;
controller.searchFieldFocusNode.requestFocus();
},
onEditingComplete: () {
controller.searchFieldFocusNode.requestFocus();
Expand Down

0 comments on commit 8b514b8

Please sign in to comment.