fix(client): note title not working for in-app help

This commit is contained in:
Elian Doran 2025-09-17 08:50:23 +03:00
parent fbd47025d6
commit 57004ab848
No known key found for this signature in database

View File

@ -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-only
useEffect(() => {
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();