From 388d5b054a7e271da2ae51b049ac41fc5813aa83 Mon Sep 17 00:00:00 2001 From: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Date: Tue, 7 Mar 2023 16:09:17 +0530 Subject: [PATCH] fix: text selection moving when typing in between (#384) --- apps/app/components/rich-text-editor/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/app/components/rich-text-editor/index.tsx b/apps/app/components/rich-text-editor/index.tsx index 1413ed6cb..3f4cfc740 100644 --- a/apps/app/components/rich-text-editor/index.tsx +++ b/apps/app/components/rich-text-editor/index.tsx @@ -153,12 +153,11 @@ const RemirrorRichTextEditor: FC = (props) => { const updateState = useCallback( (value: any) => { - // Clear out old state when setting data from outside - // This prevents e.g. the user from using CTRL-Z to go back to the old state manager.view.updateState( manager.createState({ content: !value || (typeof value === "object" && Object.keys(value).length === 0) ? "" : value, + selection: value === "" ? "start" : manager.view.state.selection, }) ); },