Skip to content

Build your personal knowledge base with Trilium Notes

chore(collections): separate Not set from select options in menus

Elian Doranb482ab9c91f1
diff --git a/apps/client/src/widgets/collections/attribute_menu.spec.ts b/apps/client/src/widgets/collections/attribute_menu.spec.ts
index 9338c4f46e..8ad94b1809 100644
--- a/apps/client/src/widgets/collections/attribute_menu.spec.ts
+++ b/apps/client/src/widgets/collections/attribute_menu.spec.ts
@@ -141,11 +141,12 @@ describe("buildAttributeMenuItems", () => {
return entry.items ?? [];
}
- it("offers the options as defined, above nothing but Not set, and no icons", () => {
+ it("offers the options as defined, below Not set and a separator, and no icons", () => {
const items = options(buildNote({ title: "Card" }));
expect(titles(items)).toEqual([
`<span class="tn-menu-name">attribute_menu.not-set</span>`,
+ "separator",
`<span class="tn-menu-name">To Do</span>`,
`<span class="tn-menu-name">Doing</span>`,
`<span class="tn-menu-name">Done</span>`
@@ -172,7 +173,7 @@ describe("buildAttributeMenuItems", () => {
const note = buildNote({ title: "Card", "#state": "Doing" });
const items = options(note);
- pick(items[2]);
+ pick(items[3]);
expect(writes.setLabelValues).toHaveBeenCalledWith(note, "state", [ "Doing" ]);
pick(items[0]);
@@ -202,7 +203,7 @@ describe("buildAttributeMenuItems", () => {
const first = buildNote({ title: "One" });
const second = buildNote({ title: "Two", "#state": "Done" });
- await pick(options(first, second)[2]);
+ await pick(options(first, second)[3]);
expect(writes.setLabelValues).toHaveBeenCalledWith(first, "state", [ "Doing" ]);
expect(writes.setLabelValues).toHaveBeenCalledWith(second, "state", [ "Doing" ]);
@@ -308,7 +309,7 @@ describe("buildAttributeMenuItems", () => {
const escaped = "<span class=\"tn-menu-name\">"
+ "&lt;img src&#x3D;x onerror&#x3D;&quot;alert(1)&quot;&gt;</span>";
expect(titles(items)[1]).toBe(escaped);
- expect(titles(entry.items ?? [])[1]).toBe(escaped);
+ expect(titles(entry.items ?? [])[2]).toBe(escaped);
});
});
diff --git a/apps/client/src/widgets/collections/attribute_menu.ts b/apps/client/src/widgets/collections/attribute_menu.ts
index e5ec292029..6be70618a3 100644
--- a/apps/client/src/widgets/collections/attribute_menu.ts
+++ b/apps/client/src/widgets/collections/attribute_menu.ts
@@ -119,6 +119,7 @@ function buildSelectItem<T>(
trailingIcon: current.agreed && !current.value ? CHECK : undefined,
handler: () => { void clearLabelOnNotes(notes, attribute.name); }
},
+ { kind: "separator" },
...options.map<MenuItem<T>>((option) => ({
title: menuName(option),
trailingIcon: current.agreed && current.value === option ? CHECK : undefined,