Skip to content

Commit

Permalink
fix: regain focus after navigation arrows are used (#878)
Browse files Browse the repository at this point in the history
* feat: retain focus to input field after navigation

* chore: add comment and use 10 ms instead of 1
  • Loading branch information
MayurSMahajan authored Sep 8, 2024
1 parent 5eca3be commit 2110fde
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/src/editor/find_replace_menu/find_replace_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,30 @@ class _FindMenuState extends State<FindMenu> {
// previous match button
FindAndReplaceMenuIconButton(
iconButtonKey: const Key('previousMatchButton'),
onPressed: () => widget.searchService.navigateToMatch(moveUp: true),
onPressed: () {
// work around to request focus back to the input field
Future.delayed(const Duration(milliseconds: 10), () {
FocusScope.of(context).requestFocus(
findTextFieldFocusNode,
);
});
widget.searchService.navigateToMatch(moveUp: true);
},
icon: const Icon(Icons.arrow_upward),
tooltip: widget.localizations?.previousMatch ??
AppFlowyEditorL10n.current.previousMatch,
),
// next match button
FindAndReplaceMenuIconButton(
iconButtonKey: const Key('nextMatchButton'),
onPressed: () => widget.searchService.navigateToMatch(),
onPressed: () {
Future.delayed(const Duration(milliseconds: 10), () {
FocusScope.of(context).requestFocus(
findTextFieldFocusNode,
);
});
widget.searchService.navigateToMatch();
},
icon: const Icon(Icons.arrow_downward),
tooltip: widget.localizations?.nextMatch ??
AppFlowyEditorL10n.current.nextMatch,
Expand Down

0 comments on commit 2110fde

Please sign in to comment.