From d8c64aa9e9b22f0b6222c8eff39727fe1971f4c1 Mon Sep 17 00:00:00 2001 From: adriangohjw Date: Fri, 10 Jan 2025 01:46:05 +0800 Subject: [PATCH 1/2] fix - set selection on update --- .../renderers/controls/JsonFormsProseControl.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/studio/src/features/editing-experience/components/form-builder/renderers/controls/JsonFormsProseControl.tsx b/apps/studio/src/features/editing-experience/components/form-builder/renderers/controls/JsonFormsProseControl.tsx index c81fd5876..72a4264ac 100644 --- a/apps/studio/src/features/editing-experience/components/form-builder/renderers/controls/JsonFormsProseControl.tsx +++ b/apps/studio/src/features/editing-experience/components/form-builder/renderers/controls/JsonFormsProseControl.tsx @@ -91,8 +91,11 @@ export function JsonFormsProseControl({ // Needed to force the value to be set when user clicks on "Go back to editing" in the exit modal useEffect(() => { if (data !== undefined) { + const selection = editor?.state.selection + if (!selection) return // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - editor?.commands.setContent(data) + editor.commands.setContent(data, false) + editor.commands.setTextSelection(selection) } }, [data]) From f75c3a2b4f9383d1fe3c7f259fbdb5acd0464d6a Mon Sep 17 00:00:00 2001 From: adriangohjw Date: Mon, 13 Jan 2025 16:30:05 +0800 Subject: [PATCH 2/2] remove 2nd argument --- .../form-builder/renderers/controls/JsonFormsProseControl.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/studio/src/features/editing-experience/components/form-builder/renderers/controls/JsonFormsProseControl.tsx b/apps/studio/src/features/editing-experience/components/form-builder/renderers/controls/JsonFormsProseControl.tsx index 72a4264ac..709639e36 100644 --- a/apps/studio/src/features/editing-experience/components/form-builder/renderers/controls/JsonFormsProseControl.tsx +++ b/apps/studio/src/features/editing-experience/components/form-builder/renderers/controls/JsonFormsProseControl.tsx @@ -94,7 +94,7 @@ export function JsonFormsProseControl({ const selection = editor?.state.selection if (!selection) return // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - editor.commands.setContent(data, false) + editor.commands.setContent(data) editor.commands.setTextSelection(selection) } }, [data])