diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/slash_handler.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/slash_handler.dart index 5c476cd139..9a3be2b887 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/slash_handler.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/slash_handler.dart @@ -106,13 +106,19 @@ void showPopupList( .removeListener(clearPopupList); editorState.service.selectionService.currentSelection .addListener(clearPopupList); + + editorState.service.scrollService?.disable(); } void clearPopupList() { + if (_popupListOverlay == null || _editorState == null) { + return; + } _popupListOverlay?.remove(); _popupListOverlay = null; _editorState?.service.keyboardService?.enable(); + _editorState?.service.scrollService?.enable(); _editorState = null; } @@ -215,11 +221,13 @@ class _PopupListWidgetState extends State { widget.items[selectedIndex].handler(widget.editorState); return KeyEventResult.handled; } - } - - if (event.logicalKey == LogicalKeyboardKey.escape) { + } else if (event.logicalKey == LogicalKeyboardKey.escape) { clearPopupList(); return KeyEventResult.handled; + } else if (event.logicalKey == LogicalKeyboardKey.backspace) { + clearPopupList(); + _deleteSlash(); + return KeyEventResult.handled; } var newSelectedIndex = selectedIndex; diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/scroll_service.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/scroll_service.dart index c3a0a6fedc..af48a78c49 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/scroll_service.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/scroll_service.dart @@ -6,7 +6,8 @@ mixin FlowyScrollService on State { void scrollTo(double dy); - RenderObject? scrollRenderObject(); + void enable(); + void disable(); } class FlowyScroll extends StatefulWidget { @@ -25,6 +26,8 @@ class _FlowyScrollState extends State with FlowyScrollService { final _scrollController = ScrollController(); final _scrollViewKey = GlobalKey(); + bool _scrollEnabled = true; + @override double get dy => _scrollController.position.pixels; @@ -51,15 +54,22 @@ class _FlowyScrollState extends State with FlowyScrollService { ); } + @override + void disable() { + _scrollEnabled = false; + debugPrint('[scroll] $_scrollEnabled'); + } + + @override + void enable() { + _scrollEnabled = true; + debugPrint('[scroll] $_scrollEnabled'); + } + void _onPointerSignal(PointerSignalEvent event) { - if (event is PointerScrollEvent) { + if (event is PointerScrollEvent && _scrollEnabled) { final dy = (_scrollController.position.pixels + event.scrollDelta.dy); scrollTo(dy); } } - - @override - RenderObject? scrollRenderObject() { - return _scrollViewKey.currentContext?.findRenderObject(); - } } diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart index a1506bf140..ecf8caf817 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart @@ -267,6 +267,7 @@ class _FlowySelectionState extends State editorState.updateCursorSelection(selection); editorState.service.keyboardService?.enable(); + editorState.service.scrollService?.enable(); } @override