Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: Esc not working for Find-Replace menu(#6955) (#6965)

Morn0bf706f43866
diff --git a/frontend/appflowy_flutter/integration_test/desktop/document/document_find_menu_test.dart b/frontend/appflowy_flutter/integration_test/desktop/document/document_find_menu_test.dart
index 1603dc7937..adb2090563 100644
--- a/frontend/appflowy_flutter/integration_test/desktop/document/document_find_menu_test.dart
+++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_find_menu_test.dart
@@ -139,6 +139,23 @@ void main() {
),
findsOneWidget,
);
+
+ /// press cmd/ctrl+F to display the find menu
+ await tester.simulateKeyEvent(
+ LogicalKeyboardKey.keyF,
+ isControlPressed:
+ UniversalPlatform.isLinux || UniversalPlatform.isWindows,
+ isMetaPressed: UniversalPlatform.isMacOS,
+ );
+ await tester.pumpAndSettle();
+
+ expect(find.byType(FindAndReplaceMenuWidget), findsOneWidget);
+
+ /// press esc to dismiss the find menu
+ await tester.simulateKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pumpAndSettle();
+ expect(find.byType(FindAndReplaceMenuWidget), findsNothing);
+
},
);
}
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/find_and_replace/find_and_replace_menu.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/find_and_replace/find_and_replace_menu.dart
index 0fee679a42..2d65c602f5 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/find_and_replace/find_and_replace_menu.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/find_and_replace/find_and_replace_menu.dart
@@ -4,6 +4,7 @@ import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
class FindAndReplaceMenuWidget extends StatefulWidget {
const FindAndReplaceMenuWidget({
@@ -55,35 +56,47 @@ class _FindAndReplaceMenuWidgetState extends State<FindAndReplaceMenuWidget> {
@override
Widget build(BuildContext context) {
- return TextFieldTapRegion(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: const EdgeInsets.symmetric(vertical: 8.0),
- child: FindMenu(
- onDismiss: widget.onDismiss,
- editorState: widget.editorState,
- searchService: searchService,
- focusNode: findFocusNode,
- showReplaceMenu: showReplaceMenu,
- onToggleShowReplace: () => setState(() {
- showReplaceMenu = !showReplaceMenu;
- }),
- ),
+ return Shortcuts(
+ shortcuts: const {
+ SingleActivator(LogicalKeyboardKey.escape): DismissIntent(),
+ },
+ child: Actions(
+ actions: {
+ DismissIntent: CallbackAction<DismissIntent>(
+ onInvoke: (t) => widget.onDismiss.call(),
),
- if (showReplaceMenu)
- Padding(
- padding: const EdgeInsets.only(
- bottom: 8.0,
- ),
- child: ReplaceMenu(
- editorState: widget.editorState,
- searchService: searchService,
- focusNode: replaceFocusNode,
+ },
+ child: TextFieldTapRegion(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(vertical: 8.0),
+ child: FindMenu(
+ onDismiss: widget.onDismiss,
+ editorState: widget.editorState,
+ searchService: searchService,
+ focusNode: findFocusNode,
+ showReplaceMenu: showReplaceMenu,
+ onToggleShowReplace: () => setState(() {
+ showReplaceMenu = !showReplaceMenu;
+ }),
+ ),
),
- ),
- ],
+ if (showReplaceMenu)
+ Padding(
+ padding: const EdgeInsets.only(
+ bottom: 8.0,
+ ),
+ child: ReplaceMenu(
+ editorState: widget.editorState,
+ searchService: searchService,
+ focusNode: replaceFocusNode,
+ ),
+ ),
+ ],
+ ),
+ ),
),
);
}