Skip to content

Build your personal knowledge base with Trilium Notes

fix(client): formatting toolbar not always disabled after temporarily editing note in old layout (closes #8091)

Elian Doran337e3fdab588
diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx
index 466339e2d2..4ee79f33ea 100644
--- a/apps/client/src/widgets/react/hooks.tsx
+++ b/apps/client/src/widgets/react/hooks.tsx
@@ -404,6 +404,10 @@ export function useNoteContext() {
setHoistedNoteId(noteContext.hoistedNoteId);
setNotePath(noteContext.notePath);
setViewScope(noteContext.viewScope);
+ // Navigating resets the view scope, so the temporary "enable editing" toggle must be reset too.
+ // Otherwise the stale value prevents consumers (e.g. the ribbon) from refreshing when the user
+ // re-enables editing on a note that was previously made temporarily editable.
+ setIsReadOnlyTemporarilyDisabled(noteContext?.viewScope?.readOnlyTemporarilyDisabled);
});
useTriliumEvent("frocaReloaded", () => {
setNote(noteContext?.note);
@@ -472,6 +476,9 @@ export function useActiveNoteContext() {
setHoistedNoteId(noteContext?.hoistedNoteId);
setNotePath(noteContext?.notePath);
setViewScope(noteContext?.viewScope);
+ // Navigating resets the view scope, so the temporary "enable editing" toggle must be reset too,
+ // otherwise the stale value prevents consumers from refreshing when editing is re-enabled.
+ setIsReadOnlyTemporarilyDisabled(noteContext?.viewScope?.readOnlyTemporarilyDisabled);
});
useTriliumEvent("frocaReloaded", () => {
setNote(noteContext?.note);