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: the popup list position is too lower

Lucas.Xu6913550f929e
diff --git a/frontend/app_flowy/packages/flowy_editor/lib/src/service/internal_key_event_handlers/slash_handler.dart b/frontend/app_flowy/packages/flowy_editor/lib/src/service/internal_key_event_handlers/slash_handler.dart
index 8316ea85d5..2023454a79 100644
--- a/frontend/app_flowy/packages/flowy_editor/lib/src/service/internal_key_event_handlers/slash_handler.dart
+++ b/frontend/app_flowy/packages/flowy_editor/lib/src/service/internal_key_event_handlers/slash_handler.dart
@@ -82,13 +82,10 @@ FlowyKeyEventHandler slashShortcutHandler = (editorState, event) {
if (selection == null || context == null || selectable == null) {
return KeyEventResult.ignored;
}
-
- final rect = selectable.getCursorRectInPosition(selection.start);
- if (rect == null) {
+ final selectionRects = editorState.service.selectionService.selectionRects;
+ if (selectionRects.isEmpty) {
return KeyEventResult.ignored;
}
- final offset = selectable.localToGlobal(rect.topLeft);
-
TransactionBuilder(editorState)
..replaceText(textNode, selection.start.offset,
selection.end.offset - selection.start.offset, event.character ?? '')
@@ -96,7 +93,8 @@ FlowyKeyEventHandler slashShortcutHandler = (editorState, event) {
_editorState = editorState;
WidgetsBinding.instance.addPostFrameCallback((_) {
- showPopupList(context, editorState, offset);
+ _selectionChangeBySlash = false;
+ showPopupList(context, editorState, selectionRects.first.bottomRight);
});
return KeyEventResult.handled;
@@ -107,8 +105,8 @@ void showPopupList(
_popupListOverlay?.remove();
_popupListOverlay = OverlayEntry(
builder: (context) => Positioned(
- top: offset.dy + 20.0,
- left: offset.dx + 5.0,
+ top: offset.dy,
+ left: offset.dx,
child: PopupListWidget(
editorState: editorState,
items: _popupListItems,