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.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix: block option interceptor (#6739)
Mathias Mogensen97999aee44db
diff --git a/frontend/appflowy_flutter/integration_test/desktop/document/document_block_option_test.dart b/frontend/appflowy_flutter/integration_test/desktop/document/document_block_option_test.dartnew file mode 100644index 0000000000..76e5dfcb6c--- /dev/null+++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_block_option_test.dart@@ -0,0 +1,47 @@+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:integration_test/integration_test.dart';++import '../../shared/util.dart';++void main() {+ IntegrationTestWidgetsFlutterBinding.ensureInitialized();++ group('Block option interaction tests', () {+ testWidgets('has correct block selection on tap option button',+ (tester) async {+ await tester.initializeAppFlowy();+ await tester.tapAnonymousSignInButton();++ // We edit the document by entering some characters, to ensure the document has focus+ await tester.editor.updateSelection(+ Selection.collapsed(Position(path: [2])),+ );++ // Insert character 'a' three times - easy to identify+ await tester.ime.insertText('aaa');+ await tester.pumpAndSettle();++ final editorState = tester.editor.getCurrentEditorState();+ final node = editorState.getNodeAtPath([2]);+ expect(node?.delta?.toPlainText(), startsWith('aaa'));++ final multiSelection = Selection(+ start: Position(path: [2], offset: 3),+ end: Position(path: [4], offset: 40),+ );++ // Select multiple items+ await tester.editor.updateSelection(multiSelection);+ await tester.pumpAndSettle();++ // Press the block option menu+ await tester.editor.hoverAndClickOptionMenuButton([2]);+ await tester.pumpAndSettle();++ // Expect the selection to be Block type and not have changed+ expect(editorState.selectionType, SelectionType.block);+ expect(editorState.selection, multiSelection);+ });+ });+}diff --git a/frontend/appflowy_flutter/integration_test/desktop/document/document_test_runner_4.dart b/frontend/appflowy_flutter/integration_test/desktop/document/document_test_runner_4.dartindex df4599836e..cfe2e640eb 100644--- a/frontend/appflowy_flutter/integration_test/desktop/document/document_test_runner_4.dart+++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_test_runner_4.dart@@ -8,6 +8,7 @@ import 'document_with_file_test.dart' as document_with_file_test;import 'document_with_image_block_test.dart' as document_with_image_block_test;import 'document_with_multi_image_block_test.dart'as document_with_multi_image_block_test;+import 'document_block_option_test.dart' as document_block_option_test;void main() {IntegrationTestWidgetsFlutterBinding.ensureInitialized();@@ -19,7 +20,5 @@ void main() {document_more_actions_test.main();document_with_file_test.main();document_shortcuts_test.main();-- // Disable subPage test temporarily, enable it in version 0.7.2- // document_sub_page_test.main();+ document_block_option_test.main();}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/option_button.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/option_button.dartindex 97abb9c0a6..bc5ac58ff6 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/option_button.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/drag_to_reorder/option_button.dart@@ -30,8 +30,10 @@ class OptionButton extends StatefulWidget {}class _OptionButtonState extends State<OptionButton> {+ late final registerKey =+ _interceptorKey + widget.blockComponentContext.node.id;late final gestureInterceptor = SelectionGestureInterceptor(- key: _interceptorKey,+ key: registerKey,canTap: (details) => !_isTapInBounds(details.globalPosition),);@@ -52,7 +54,7 @@ class _OptionButtonState extends State<OptionButton> {@overridevoid dispose() {widget.editorState.service.selectionService.unregisterGestureInterceptor(- _interceptorKey,+ registerKey,);super.dispose();