Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: cursor jumps to editor from title

thecodrr6ba0e42a7fb6
diff --git a/apps/web/src/components/editor/index.js b/apps/web/src/components/editor/index.js
index 89ea09b0c..b9f973a79 100644
--- a/apps/web/src/components/editor/index.js
+++ b/apps/web/src/components/editor/index.js
@@ -90,12 +90,13 @@ function Editor({ noteId, nonce }) {
[newSession, openSession, nonce]
);
- const clearContent = useCallback(() => {
+ const clearContent = useCallback((focus) => {
const editor = editorRef.current?.editor;
if (!editor || !editor.initialized) return;
editor.clearContent();
updateWordCount(editor);
- editor.focus(); // TODO
+ if (focus) editor.focus(); // TODO
+ // console.trace("HELLO");
}, []);
const setContent = useCallback(() => {
@@ -114,7 +115,7 @@ function Editor({ noteId, nonce }) {
let content = await editorstore.get().getSessionContent();
if (content?.data) editorSetContent(editor, content.data);
- else clearContent(editor);
+ else clearContent();
editorstore.set((state) => (state.session.state = SESSION_STATES.stale));
if (id && content) await db.attachments.downloadImages(id);
@@ -181,7 +182,7 @@ function Editor({ noteId, nonce }) {
function newSession() {
if (!nonce) return;
- clearContent();
+ clearContent(true);
},
[nonce, clearContent]
);