fix(client): edge case not handled when parent note overrides to false

This commit is contained in:
Elian Doran 2026-01-10 11:25:00 +02:00
parent 6398830c2d
commit 26c25cd4cd
No known key found for this signature in database
2 changed files with 39 additions and 1 deletions

View File

@ -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}`);
});
});

View File

@ -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 {