Skip to content

Open-source and local-first Slack and Notion alternative that puts you in control of your data

Return to previous selection state after content update

Hakan Shehu0e2b67565d9a
diff --git a/desktop/src/components/documents/document-editor.tsx b/desktop/src/components/documents/document-editor.tsx
index ed22c3da..ddf4a557 100644
--- a/desktop/src/components/documents/document-editor.tsx
+++ b/desktop/src/components/documents/document-editor.tsx
@@ -297,7 +297,12 @@ export const DocumentEditor = ({ node, nodes }: DocumentEditorProps) => {
newEditorNodes,
);
- editor.commands.setContent(newEditorContent);
+ const selection = editor.state.selection;
+ editor
+ .chain()
+ .setContent(newEditorContent)
+ .setTextSelection(selection)
+ .run();
nodesSnapshot.current = newEditorNodes;
}, 100),
[node.id],