Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(client): note title not working for in-app help
Elian Doran57004ab8480f
diff --git a/apps/client/src/widgets/note_title.tsx b/apps/client/src/widgets/note_title.tsxindex bce3b289dc..b3323fb1c5 100644--- a/apps/client/src/widgets/note_title.tsx+++ b/apps/client/src/widgets/note_title.tsx@@ -11,14 +11,14 @@ import branches from "../services/branches";import { isIMEComposing } from "../services/shortcuts";export default function NoteTitleWidget() {- const { note, noteId, componentId, viewScope, noteContext, parentComponent } = useNoteContext();- const title = useNoteProperty(note, "title", componentId);+ const { note, noteId, componentId, viewScope, noteContext, parentComponent } = useNoteContext();+ const title = useNoteProperty(note, "title", componentId);const isProtected = useNoteProperty(note, "isProtected");const newTitle = useRef("");-+const [ isReadOnly, setReadOnly ] = useState<boolean>(false);- const [ navigationTitle, setNavigationTitle ] = useState<string | null>(null);-+ const [ navigationTitle, setNavigationTitle ] = useState<string | null>(null);+// Manage read-onlyuseEffect(() => {const isReadOnly = note === null@@ -34,7 +34,7 @@ export default function NoteTitleWidget() {if (isReadOnly) {noteContext?.getNavigationTitle().then(setNavigationTitle);}- }, [isReadOnly]);+ }, [noteContext, isReadOnly]);// Save changes to title.const spacedUpdate = useSpacedUpdate(async () => {@@ -43,11 +43,11 @@ export default function NoteTitleWidget() {}protected_session_holder.touchProtectedSessionIfNecessary(note);await server.put<void>(`notes/${noteId}/title`, { title: newTitle.current }, componentId);- });+ });// Prevent user from navigating away if the spaced update is not done.useEffect(() => {- appContext.addBeforeUnloadListener(() => spacedUpdate.isAllSavedAndTriggerUpdate());+ appContext.addBeforeUnloadListener(() => spacedUpdate.isAllSavedAndTriggerUpdate());}, []);useTriliumEvents([ "beforeNoteSwitch", "beforeNoteContextRemove" ], () => spacedUpdate.updateNowIfNecessary());@@ -84,7 +84,7 @@ export default function NoteTitleWidget() {if (isIMEComposing(e)) {return;}-+// Focus on the note content when pressing enter.if (e.key === "Enter") {e.preventDefault();