From 26c25cd4cdbfe6767d9631434f2e8cf88818eae2 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 10 Jan 2026 11:25:00 +0200 Subject: [PATCH] fix(client): edge case not handled when parent note overrides to false --- apps/client/src/services/attributes.spec.ts | 38 +++++++++++++++++++++ apps/client/src/services/attributes.ts | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/apps/client/src/services/attributes.spec.ts b/apps/client/src/services/attributes.spec.ts index cd52cb6d5..13be02765 100644 --- a/apps/client/src/services/attributes.spec.ts +++ b/apps/client/src/services/attributes.spec.ts @@ -110,4 +110,42 @@ describe("Set boolean with inheritance", () => { await setBooleanWithInheritance(childNote, "foo", true); expect(server.remove).toHaveBeenCalledWith(`notes/${childNote.noteId}/attributes/${childNote.getLabel("foo")!.attributeId}`); }); + + it("overrides boolean with inherited false", async () => { + const parentNote = buildNote({ + title: "Parent note", + "#foo(inheritable)": "false", + "children": [ + { + title: "Child note" + } + ] + }); + const childNote = froca.getNoteFromCache(parentNote.children[0])!; + expect(childNote.isLabelTruthy("foo")).toBe(false); + await setBooleanWithInheritance(childNote, "foo", true); + expect(server.put).toHaveBeenCalledWith(`notes/${childNote.noteId}/set-attribute`, { + type: "label", + name: "foo", + value: "", + isInheritable: false + }); + }); + + it("deletes override boolean with inherited false with already existing value", async () => { + const parentNote = buildNote({ + title: "Parent note", + "#foo(inheritable)": "false", + "children": [ + { + title: "Child note", + "#foo": "false", + } + ] + }); + const childNote = froca.getNoteFromCache(parentNote.children[0])!; + expect(childNote.isLabelTruthy("foo")).toBe(false); + await setBooleanWithInheritance(childNote, "foo", true); + expect(server.remove).toHaveBeenCalledWith(`notes/${childNote.noteId}/attributes/${childNote.getLabel("foo")!.attributeId}`); + }); }); diff --git a/apps/client/src/services/attributes.ts b/apps/client/src/services/attributes.ts index 34c07d638..2f0a1202d 100644 --- a/apps/client/src/services/attributes.ts +++ b/apps/client/src/services/attributes.ts @@ -48,7 +48,7 @@ export async function setBooleanWithInheritance(note: FNote, labelName: string, if (actualValue === value) return; if (value) { - if (note.getLabelValue(labelName) === "false") { + if (note.getOwnedLabelValue(labelName) === "false") { // Remove the override so that the inherited true takes effect. removeOwnedLabelByName(note, labelName); } else {