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.

feat: disable scroll when showing popuplist

Lucas.Xu27ea5a11a9dd
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,10 +221,12 @@ class _PopupListWidgetState extends State<PopupListWidget> {
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;
}
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<T extends StatefulWidget> on State<T> {
void scrollTo(double dy);
- RenderObject? scrollRenderObject();
+ void enable();
+ void disable();
}
class FlowyScroll extends StatefulWidget {
@@ -25,6 +26,8 @@ class _FlowyScrollState extends State<FlowyScroll> 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<FlowyScroll> 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<FlowySelection>
editorState.updateCursorSelection(selection);
editorState.service.keyboardService?.enable();
+ editorState.service.scrollService?.enable();
}
@override