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: update the selection after render completed

Lucas.Xu90fa1312f2b3
diff --git a/frontend/app_flowy/packages/flowy_editor/lib/editor_state.dart b/frontend/app_flowy/packages/flowy_editor/lib/editor_state.dart
index 92a05fc880..5ea49c644d 100644
--- a/frontend/app_flowy/packages/flowy_editor/lib/editor_state.dart
+++ b/frontend/app_flowy/packages/flowy_editor/lib/editor_state.dart
@@ -60,10 +60,8 @@ class EditorState {
for (final op in transaction.operations) {
_applyOperation(op);
}
- // updateCursorSelection(transaction.afterSelection);
- // FIXME: don't use delay
- Future.delayed(const Duration(milliseconds: 16), () {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
updateCursorSelection(transaction.afterSelection);
});
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 02975df1e1..db3db2e1ad 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
@@ -153,8 +153,6 @@ class _PopupListWidgetState extends State<PopupListWidget> {
@override
Widget build(BuildContext context) {
- // TODO: Is there a better way to get focus?
-
return Focus(
focusNode: focusNode,
onKey: _onKey,