From 90fa1312f2b32142fda08397038287009b66616c Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Wed, 3 Aug 2022 22:53:19 +0800 Subject: [PATCH] fix: update the selection after render completed --- .../app_flowy/packages/flowy_editor/lib/editor_state.dart | 4 +--- .../service/internal_key_event_handlers/slash_handler.dart | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) 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 { @override Widget build(BuildContext context) { - // TODO: Is there a better way to get focus? - return Focus( focusNode: focusNode, onKey: _onKey,