Skip to content

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

feat: focus editor instead of title on note open

thecodrrc51f507eec9d
diff --git a/apps/web/src/components/editor/header.js b/apps/web/src/components/editor/header.js
index 06f91bb03..63b2c3ede 100644
--- a/apps/web/src/components/editor/header.js
+++ b/apps/web/src/components/editor/header.js
@@ -1,16 +1,14 @@
import React from "react";
import TitleBox from "./title-box";
-import { useStore, SESSION_STATES } from "../../stores/editor-store";
+import { useStore } from "../../stores/editor-store";
function Header() {
const title = useStore((store) => store.session.title);
- const sessionState = useStore((store) => store.session.state);
const setSession = useStore((store) => store.setSession);
return (
<TitleBox
- shouldFocus={sessionState === SESSION_STATES.new && title.length <= 0}
title={title}
changeInterval={500}
setTitle={(title) =>
diff --git a/apps/web/src/components/editor/index.js b/apps/web/src/components/editor/index.js
index 26dea4550..5b72e7111 100644
--- a/apps/web/src/components/editor/index.js
+++ b/apps/web/src/components/editor/index.js
@@ -52,7 +52,7 @@ function Editor({ noteId, nonce }) {
(async () => {
await startSession(noteId);
})();
- }, [startSession, noteId]);
+ }, [startSession, noteId, nonce]);
useEffect(() => {
if (sessionState === SESSION_STATES.new) {
@@ -70,13 +70,16 @@ function Editor({ noteId, nonce }) {
editor.undoManager.reset();
editor.setDirty(false);
}
+
+ if (!isMobile) editor.focus();
+
setContents();
editor.on("init", setContents);
return () => {
editor.off("init", setContents);
};
}
- }, [editorRef, contentType, sessionState, sessionNonce]);
+ }, [editorRef, isMobile, contentType, sessionState, sessionNonce]);
return (
<Flex