Skip to content

Build your personal knowledge base with Trilium Notes

feat(menu): keep a checked row's own icon, checking it at the trailing edge

Elian Doran53b9733668e6
diff --git a/apps/client/src/menus/context_menu.spec.ts b/apps/client/src/menus/context_menu.spec.ts
index d349d4e13d..5ba3f2f87c 100644
--- a/apps/client/src/menus/context_menu.spec.ts
+++ b/apps/client/src/menus/context_menu.spec.ts
@@ -172,7 +172,7 @@ describe("contextMenu", () => {
expect(row?.querySelector(".tn-menu-name")).not.toBeNull();
});
- it("shows an item's icon, a check mark in its place when checked, and a slot for none", async () => {
+ it("shows an item's icon, a check mark after a checked item with one and in its place without, and a slot for none", async () => {
buildPage();
const contextMenu = await buildContextMenu();
@@ -181,6 +181,8 @@ describe("contextMenu", () => {
items: [
{ title: "To Do", uiIcon: "bx bx-list-ul", iconColorClass: "use-note-color color-e64d4d" },
{ title: "Done", uiIcon: "bx bx-list-ul", checked: true },
+ { title: "Wrap", checked: true },
+ { title: "Blank", uiIcon: "bx bx-empty", checked: true },
{ title: "Aligned", uiIcon: undefined },
{ title: "Plain" }
]
@@ -194,6 +196,9 @@ describe("contextMenu", () => {
});
expect(slots).toEqual([
"bx bx-list-ul use-note-color color-e64d4d tn-icon",
+ // The item's own icon tells it from the others, so the check goes to the trailing edge.
+ "bx bx-list-ul tn-icon",
+ "bx bx-check tn-icon",
"bx bx-check tn-icon",
// A blank icon of an icon's width, which lines the title up with the others.
"bx bx-empty tn-icon",
@@ -201,6 +206,9 @@ describe("contextMenu", () => {
]);
// Only the icon is tinted, so the title keeps the menu's own colour.
expect(menuElement()?.querySelectorAll(".use-note-color")).toHaveLength(1);
+ const trailing = [ ...menuElement()?.querySelectorAll("li.dropdown-item") ?? [] ]
+ .map((row) => row.querySelector(".menu-trailing-icon")?.className ?? null);
+ expect(trailing).toEqual([ null, "bx bx-check tn-icon menu-trailing-icon", null, null, null, null ]);
});
it("shows a keyboard action's shortcuts, or a literal shortcut, after the title", async () => {
diff --git a/apps/client/src/menus/context_menu.ts b/apps/client/src/menus/context_menu.ts
index d5ea715338..1ad3858188 100644
--- a/apps/client/src/menus/context_menu.ts
+++ b/apps/client/src/menus/context_menu.ts
@@ -63,15 +63,14 @@ export interface MenuCommandItem<T> {
shortcut?: string;
keyboardShortcut?: KeyboardActionNames;
spellingSuggestion?: string;
+ /**
+ * Makes the item a checkable one and says whether it is checked. The check shows at the trailing
+ * edge when the item has a {@link uiIcon} of its own, and in place of the icon when it has none.
+ */
checked?: boolean;
/** Classes put on the item itself, for a menu styling one of its entries differently. */
className?: string;
- /**
- * An icon shown at the trailing edge of the item, where a shortcut would go.
- *
- * Unlike {@link checked}, which takes the place of {@link uiIcon}, this leaves the item's own
- * icon standing — for a list where that icon is what tells one entry from another.
- */
+ /** An icon shown at the trailing edge of the item, where a shortcut would go. */
trailingIcon?: string;
/**
* For an item with {@link items}: typing while its submenu is open filters every item inside
diff --git a/apps/client/src/menus/link_context_menu.spec.ts b/apps/client/src/menus/link_context_menu.spec.ts
index 994f66ade8..6343557ae3 100644
--- a/apps/client/src/menus/link_context_menu.spec.ts
+++ b/apps/client/src/menus/link_context_menu.spec.ts
@@ -475,13 +475,13 @@ describe("openContextMenu", () => {
title: "link_context_menu.show_title",
uiIcon: "bx bx-window-alt",
enabled: true,
- trailingIcon: undefined
+ checked: false
},
{
title: "link_context_menu.show_caption",
uiIcon: "bx bx-captions",
enabled: true,
- trailingIcon: CHECK
+ checked: true
},
{ kind: "separator" },
{ title: "Rename" },
@@ -515,7 +515,7 @@ describe("openContextMenu", () => {
{
title: "link_context_menu.editable",
uiIcon: "bx bx-edit-alt",
- trailingIcon: CHECK
+ checked: true
},
{ title: "link_context_menu.include_size" }
]);
@@ -524,7 +524,7 @@ describe("openContextMenu", () => {
state = { ...state, isEditable: false };
expect((await openOn(editable.querySelector("a")))[7])
- .toMatchObject({ title: "link_context_menu.editable", trailingIcon: undefined });
+ .toMatchObject({ title: "link_context_menu.editable", checked: false });
});
it("appends the commands of an embedded note, its conversion in a group of its own", async () => {
@@ -554,8 +554,8 @@ describe("openContextMenu", () => {
expect((await openOn(editable.querySelector("a"), {})).slice(4)).toMatchObject([
{ kind: "separator" },
{ title: "link_context_menu.include_size" },
- { title: "link_context_menu.show_title", enabled: false, trailingIcon: CHECK },
- { title: "link_context_menu.show_caption", enabled: false, trailingIcon: undefined }
+ { title: "link_context_menu.show_title", enabled: false, checked: true },
+ { title: "link_context_menu.show_caption", enabled: false, checked: false }
]);
// A link in the embedded content, an embed the editor does not know, and an editor
diff --git a/apps/client/src/menus/link_context_menu.ts b/apps/client/src/menus/link_context_menu.ts
index f5a7d19a7c..5fc30c3d12 100644
--- a/apps/client/src/menus/link_context_menu.ts
+++ b/apps/client/src/menus/link_context_menu.ts
@@ -251,7 +251,7 @@ function getEmbedItems(embed: MenuEmbed): MenuItem<CommandNames>[] {
const editableItems: MenuItem<CommandNames>[] = state.isEditableToggleable ? [ {
title: t("link_context_menu.editable"),
uiIcon: "bx bx-edit-alt",
- trailingIcon: state.isEditable ? CHECK_ICON : undefined,
+ checked: state.isEditable,
handler: () => runEmbedCommand(embed, "toggleContentEmbedEditable")
} ] : [];
@@ -265,14 +265,14 @@ function getEmbedItems(embed: MenuEmbed): MenuItem<CommandNames>[] {
title: t("link_context_menu.show_title"),
uiIcon: "bx bx-window-alt",
enabled: state.isTitleToggleable,
- trailingIcon: state.isTitleShown ? CHECK_ICON : undefined,
+ checked: state.isTitleShown,
handler: () => runEmbedCommand(embed, "toggleContentEmbedTitle")
},
{
title: t("link_context_menu.show_caption"),
uiIcon: "bx bx-captions",
enabled: state.isCaptionToggleable,
- trailingIcon: state.hasCaption ? CHECK_ICON : undefined,
+ checked: state.hasCaption,
handler: () => runEmbedCommand(embed, "toggleContentEmbedCaption", {
focusCaptionOnShow: true
})
diff --git a/apps/client/src/menus/table_context_menu.spec.ts b/apps/client/src/menus/table_context_menu.spec.ts
index 35b63c35d2..ba3a87c4e1 100644
--- a/apps/client/src/menus/table_context_menu.spec.ts
+++ b/apps/client/src/menus/table_context_menu.spec.ts
@@ -151,13 +151,13 @@ describe("buildTableMenuSections", () => {
const firstRows = build([LATER_ROW]);
expect(titles(firstRows.main)).toEqual(MAIN_TITLES);
expect(findItem(firstRows.main, FIRST_ROWS_TITLE))
- .toMatchObject({ uiIcon: "bx bx-dock-top", trailingIcon: undefined });
+ .toMatchObject({ uiIcon: "bx bx-dock-top", checked: false });
const laterRow = build([FIRST_ROWS], [LATER_ROW]);
expect(titles(laterRow.main)).toEqual(MAIN_TITLES
.map((title) => (title === FIRST_ROWS_TITLE ? LATER_ROW_TITLE : title)));
expect(findItem(laterRow.main, LATER_ROW_TITLE))
- .toMatchObject({ uiIcon: "bx bx-arrow-to-top", trailingIcon: "bx bx-check" });
+ .toMatchObject({ uiIcon: "bx bx-arrow-to-top", checked: true });
run(laterRow.main, LATER_ROW_TITLE);
expect(laterRow.executed).toEqual([LATER_ROW]);
diff --git a/apps/client/src/menus/table_context_menu.ts b/apps/client/src/menus/table_context_menu.ts
index 41023ba993..0292a88d6c 100644
--- a/apps/client/src/menus/table_context_menu.ts
+++ b/apps/client/src/menus/table_context_menu.ts
@@ -49,7 +49,7 @@ export function buildTableMenuSections(
});
const toggleItem = (title: string, uiIcon: string, commandName: string) => ({
...commandItem(title, uiIcon, commandName),
- trailingIcon: editor.commands.get(commandName)?.value === true ? "bx bx-check" : undefined
+ checked: editor.commands.get(commandName)?.value === true
});
// One toggle under two labels: only the item enabled for the selection is shown.
diff --git a/apps/client/src/widgets/collections/attribute_menu.spec.ts b/apps/client/src/widgets/collections/attribute_menu.spec.ts
index 9b92e49136..848f1ab4a3 100644
--- a/apps/client/src/widgets/collections/attribute_menu.spec.ts
+++ b/apps/client/src/widgets/collections/attribute_menu.spec.ts
@@ -70,7 +70,7 @@ describe("buildAttributeMenuItems", () => {
const note = buildNote({ title: "Card", "#done": "true" });
const items = buildAttributeMenuItems<string>({ notes: [ note ], attributes: flag });
- expect(items[1]).toMatchObject({ trailingIcon: "bx bx-check" });
+ expect(items[1]).toMatchObject({ checked: true });
pick(items[1]);
expect(writes.setLabelValues).toHaveBeenCalledWith(note, "done", [ "false" ]);
});
@@ -79,7 +79,7 @@ describe("buildAttributeMenuItems", () => {
const note = buildNote({ title: "Card" });
const items = buildAttributeMenuItems<string>({ notes: [ note ], attributes: flag });
- expect(items[1]).toMatchObject({ trailingIcon: undefined });
+ expect(items[1]).toMatchObject({ checked: false });
pick(items[1]);
expect(writes.setLabelValues).toHaveBeenCalledWith(note, "done", [ "true" ]);
});
@@ -89,10 +89,10 @@ describe("buildAttributeMenuItems", () => {
const unset = buildNote({ title: "Two" });
expect(buildAttributeMenuItems<string>({ notes: [ set, unset ], attributes: flag })[1])
- .toMatchObject({ trailingIcon: undefined });
+ .toMatchObject({ checked: false });
expect(buildAttributeMenuItems<string>({
notes: [ set, buildNote({ title: "Three", "#done": "true" }) ], attributes: flag
- })[1]).toMatchObject({ trailingIcon: "bx bx-check" });
+ })[1]).toMatchObject({ checked: true });
});
it("writes the value to every selected item, settling a disagreement", async () => {
@@ -115,7 +115,7 @@ describe("buildAttributeMenuItems", () => {
notes: [ note ], attributes: flag
});
- expect(items[1]).toMatchObject({ trailingIcon: undefined });
+ expect(items[1]).toMatchObject({ checked: false });
}
});
});
diff --git a/apps/client/src/widgets/collections/attribute_menu.ts b/apps/client/src/widgets/collections/attribute_menu.ts
index 63c79835af..57ca7ee7e8 100644
--- a/apps/client/src/widgets/collections/attribute_menu.ts
+++ b/apps/client/src/widgets/collections/attribute_menu.ts
@@ -82,7 +82,7 @@ function buildBooleanItem<T>(notes: FNote[], attribute: PromotedAttribute): Menu
return {
...attributeEntry<T>(attribute),
- trailingIcon: isSet ? CHECK : undefined,
+ checked: isSet,
handler: () => {
void setLabelOnNotes(notes, attribute.name, isSet ? FALSE : TRUE);
}
diff --git a/apps/client/src/widgets/collections/board/context_menu.spec.ts b/apps/client/src/widgets/collections/board/context_menu.spec.ts
index 1c2373e594..fe42b92a1a 100644
--- a/apps/client/src/widgets/collections/board/context_menu.spec.ts
+++ b/apps/client/src/widgets/collections/board/context_menu.spec.ts
@@ -188,14 +188,14 @@ describe("Board column context menu", () => {
return found;
};
- // The check sits after the title, the entry keeping its own icon ahead of it.
+ // Checked, which the menu shows after the title, as the entry has an icon of its own.
const unchecked = entryOf(false);
- expect("trailingIcon" in unchecked && unchecked.trailingIcon).toBeUndefined();
+ expect("checked" in unchecked && unchecked.checked).toBe(false);
unchecked.handler?.(unchecked, {} as never);
expect(onKeepCollapsed).toHaveBeenLastCalledWith(true);
const checked = entryOf(true);
- expect("trailingIcon" in checked && checked.trailingIcon).toBe("bx bx-check");
+ expect("checked" in checked && checked.checked).toBe(true);
checked.handler?.(checked, {} as never);
expect(onKeepCollapsed).toHaveBeenLastCalledWith(false);
@@ -267,14 +267,14 @@ describe("Board column context menu", () => {
return found;
};
- // The check sits after the title, the entry keeping its own icon ahead of it.
+ // Checked, which the menu shows after the title, as the entry has an icon of its own.
const unchecked = entryOf(false);
- expect("trailingIcon" in unchecked && unchecked.trailingIcon).toBeUndefined();
+ expect("checked" in unchecked && unchecked.checked).toBe(false);
unchecked.handler?.(unchecked, {} as never);
expect(api.setInboxNested).toHaveBeenLastCalledWith(true);
const checked = entryOf(true);
- expect("trailingIcon" in checked && checked.trailingIcon).toBe("bx bx-check");
+ expect("checked" in checked && checked.checked).toBe(true);
checked.handler?.(checked, {} as never);
expect(api.setInboxNested).toHaveBeenLastCalledWith(false);
});
@@ -955,9 +955,9 @@ describe("Board item context menu", () => {
'<span class="tn-menu-name">To Do</span>',
'<span class="tn-menu-name">Done</span>'
]);
- // The tick goes at the trailing edge, leaving each column's own icon where it stands.
- expect(columns.map(item => item && "trailingIcon" in item ? item.trailingIcon : undefined))
- .toEqual([ "bx bx-check", undefined ]);
+ // Ticked, which the menu shows after the title, as each column has an icon of its own.
+ expect(columns.map(item => item && "checked" in item ? item.checked : undefined))
+ .toEqual([ true, false ]);
// And the one the card is under carries the class the stylesheet weights it by.
expect(columns.map(item => item && "className" in item ? item.className : undefined))
.toEqual([ "board-current-column", undefined ]);
@@ -1128,8 +1128,8 @@ describe("Board item context menu", () => {
} as unknown as BoardApi;
expect(marksOf(openSelectionMenu(together, notes)))
- .toEqual([ undefined, "bx bx-check" ]);
- expect(marksOf(openSelectionMenu(apart, notes))).toEqual([ undefined, undefined ]);
+ .toEqual([ false, true ]);
+ expect(marksOf(openSelectionMenu(apart, notes))).toEqual([ false, false ]);
});
it("files every card under the column picked", async () => {
@@ -1192,7 +1192,7 @@ describe("Board item context menu", () => {
function marksOf(items: MenuItem<unknown>[]) {
return columnEntries(items)
- .map(item => item && "trailingIcon" in item ? item.trailingIcon : undefined);
+ .map(item => item && "checked" in item ? item.checked : undefined);
}
function titlesOf(items: MenuItem<unknown>[]) {
diff --git a/apps/client/src/widgets/collections/board/context_menu.ts b/apps/client/src/widgets/collections/board/context_menu.ts
index 5c559787f6..a24cd70e7b 100644
--- a/apps/client/src/widgets/collections/board/context_menu.ts
+++ b/apps/client/src/widgets/collections/board/context_menu.ts
@@ -76,8 +76,7 @@ export function openColumnContextMenu(api: Api, event: ContextMenuEvent, column:
...(isInbox ? [ {
title: t("board_view.inbox-nested"),
uiIcon: "bx bx-subdirectory-right",
- // At the trailing edge, so the entry keeps its own icon in front.
- trailingIcon: column.nested ? "bx bx-check" : undefined,
+ checked: column.nested,
handler: () => api.setInboxNested(!column.nested)
} ] : []),
{
@@ -138,8 +137,7 @@ export function openColumnContextMenu(api: Api, event: ContextMenuEvent, column:
...(column.canKeepCollapsed ? [ {
title: t("board_view.keep-column-collapsed"),
uiIcon: "bx bx-lock-alt",
- // At the trailing edge, so the entry keeps its own icon in front.
- trailingIcon: column.keepCollapsed ? "bx bx-check" : undefined,
+ checked: column.keepCollapsed,
handler: () => column.onKeepCollapsed(!column.keepCollapsed)
} ] : []),
{
@@ -247,7 +245,7 @@ export function openBoardContextMenu(event: ContextMenuEvent, board: BoardMenuTa
{
title: t("board_view.show-archived-notes"),
uiIcon: "bx bx-archive",
- trailingIcon: board.archivedShown ? "bx bx-check" : undefined,
+ checked: board.archivedShown,
handler: () => board.onShowArchived(!board.archivedShown)
},
{ kind: "separator" },
@@ -447,7 +445,7 @@ function buildColumnItems(api: Api, target: NoteMenuTarget): MenuItem<CommandNam
iconColorClass: api.getColumnColorClass(name),
// The one they are already under is shown rather than hidden, so the list reads as the
// whole set of columns and says which of them the cards belong to.
- trailingIcon: name === current ? "bx bx-check" : undefined,
+ checked: name === current,
className: name === current ? "board-current-column" : undefined,
badges: api.isColumnArchived(name)
? [ { title: t("board_view.archived-badge") } ]
diff --git a/apps/client/src/widgets/collections/board/index.spec.tsx b/apps/client/src/widgets/collections/board/index.spec.tsx
index 98984c498b..8bbdbcb5ad 100644
--- a/apps/client/src/widgets/collections/board/index.spec.tsx
+++ b/apps/client/src/widgets/collections/board/index.spec.tsx
@@ -680,8 +680,8 @@ describe("Collapsed board columns", () => {
// Archived notes are not shown, so the entry is not ticked, and pressing it asks for them.
// The inbox column is turned on in the properties dialog rather than here.
- expect("trailingIcon" in entry("bx bx-archive") && entry("bx bx-archive").trailingIcon)
- .toBeUndefined();
+ expect("checked" in entry("bx bx-archive") && entry("bx bx-archive").checked)
+ .toBe(false);
entry("bx bx-archive").handler?.(entry("bx bx-archive"), {} as never);
expect(archived).toHaveBeenCalledWith(true);
diff --git a/apps/client/src/widgets/collections/sort_menu.spec.ts b/apps/client/src/widgets/collections/sort_menu.spec.ts
index 853cb96c6a..4824fdf980 100644
--- a/apps/client/src/widgets/collections/sort_menu.spec.ts
+++ b/apps/client/src/widgets/collections/sort_menu.spec.ts
@@ -37,32 +37,32 @@ describe("buildSortMenuItems", () => {
it("checks no sorting while nothing is sorted, and offers no direction", () => {
const items = build();
- expect(items[1]).toMatchObject({ trailingIcon: "bx bx-check" });
- expect(items[2]).toMatchObject({ trailingIcon: undefined });
- expect(items.at(-2)).toMatchObject({ enabled: false, trailingIcon: undefined });
- expect(items.at(-1)).toMatchObject({ enabled: false, trailingIcon: undefined });
+ expect(items[1]).toMatchObject({ checked: true });
+ expect(items[2]).toMatchObject({ checked: false });
+ expect(items.at(-2)).toMatchObject({ enabled: false, checked: false });
+ expect(items.at(-1)).toMatchObject({ enabled: false, checked: false });
});
/** The order comes from above with a direction of its own, so there is none to pick here. */
it("checks the collection's own order, and offers no direction with it", () => {
const items = build({ orderBy: "default", isDescending: true });
- expect(items[0]).toMatchObject({ trailingIcon: "bx bx-check" });
- expect(items[1]).toMatchObject({ trailingIcon: undefined });
+ expect(items[0]).toMatchObject({ checked: true });
+ expect(items[1]).toMatchObject({ checked: false });
expect(items.at(-2)).toMatchObject({ enabled: false });
- expect(items.at(-1)).toMatchObject({ enabled: false, trailingIcon: "bx bx-check" });
+ expect(items.at(-1)).toMatchObject({ enabled: false, checked: true });
});
it("checks the key it sorts by, and the direction it sorts in", () => {
const ascending = build({ orderBy: "title" });
- expect(ascending[1]).toMatchObject({ trailingIcon: undefined });
- expect(ascending[2]).toMatchObject({ trailingIcon: "bx bx-check" });
- expect(ascending.at(-2)).toMatchObject({ enabled: true, trailingIcon: "bx bx-check" });
- expect(ascending.at(-1)).toMatchObject({ enabled: true, trailingIcon: undefined });
+ expect(ascending[1]).toMatchObject({ checked: false });
+ expect(ascending[2]).toMatchObject({ checked: true });
+ expect(ascending.at(-2)).toMatchObject({ enabled: true, checked: true });
+ expect(ascending.at(-1)).toMatchObject({ enabled: true, checked: false });
const descending = build({ orderBy: "title", isDescending: true });
- expect(descending.at(-2)).toMatchObject({ trailingIcon: undefined });
- expect(descending.at(-1)).toMatchObject({ trailingIcon: "bx bx-check" });
+ expect(descending.at(-2)).toMatchObject({ checked: false });
+ expect(descending.at(-1)).toMatchObject({ checked: true });
});
it("lists the attributes under the built-in keys, each with its own icon", () => {
@@ -78,8 +78,8 @@ describe("buildSortMenuItems", () => {
`<span class="tn-menu-name">Due date</span>`,
`<span class="tn-menu-name">Owner</span>`
]);
- expect(items[4]).toMatchObject({ uiIcon: "bx bx-calendar", trailingIcon: undefined });
- expect(items[5]).toMatchObject({ uiIcon: "bx bx-transfer", trailingIcon: "bx bx-check" });
+ expect(items[4]).toMatchObject({ uiIcon: "bx bx-calendar", checked: false });
+ expect(items[5]).toMatchObject({ uiIcon: "bx bx-transfer", checked: true });
});
it("escapes what a crafted attribute name would plant in the menu", () => {
diff --git a/apps/client/src/widgets/collections/sort_menu.ts b/apps/client/src/widgets/collections/sort_menu.ts
index 6bdc92735b..f3eec6436b 100644
--- a/apps/client/src/widgets/collections/sort_menu.ts
+++ b/apps/client/src/widgets/collections/sort_menu.ts
@@ -142,13 +142,13 @@ export function buildSortMenuItems<T>(options: SortMenuOptions): MenuItem<T>[] {
];
}
-/** One entry as a menu reads it: a title of markup, the mark at the trailing edge. */
+/** One entry as a menu reads it: a title of markup, checked when selected. */
function toMenuItem<T>(entry: SortEntry): MenuItem<T> {
return {
title: entry.isUserNamed ? menuName(entry.title) : entry.title,
uiIcon: entry.icon,
enabled: entry.isEnabled,
- trailingIcon: entry.isSelected ? "bx bx-check" : undefined,
+ checked: entry.isSelected,
handler: () => entry.pick()
};
}
diff --git a/apps/client/src/widgets/react/FormList.tsx b/apps/client/src/widgets/react/FormList.tsx
index 3d89f1d0d2..312a98981c 100644
--- a/apps/client/src/widgets/react/FormList.tsx
+++ b/apps/client/src/widgets/react/FormList.tsx
@@ -148,6 +148,10 @@ export interface FormListItemOpts {
disabled?: boolean;
/** Will indicate the reason why the item is disabled via an icon, when hovered over it. */
disabledTooltip?: string;
+ /**
+ * Marks the row with a check: at the trailing edge when the row has an {@link icon} of its own,
+ * which tells it from the other rows, and in place of the icon when it has none.
+ */
checked?: boolean | null;
selected?: boolean;
container?: boolean;
@@ -171,14 +175,14 @@ export interface FormListItemOpts {
keyboardShortcut?: KeyboardActionNames;
/** A shortcut shown as it is written, for a row with no action of its own. */
shortcut?: string;
- /**
- * An icon at the end of the row, where a shortcut would go. Unlike {@link checked}, which takes
- * the place of {@link icon}, this leaves the row's own icon standing, for a list where that icon
- * is what tells one row from another.
- */
+ /** An icon at the end of the row, where a shortcut would go. */
trailingIcon?: string;
}
+const CHECK_ICON = "bx bx-check";
+/** The blank icon a row carries only to line its title up with the icons of the others. */
+const EMPTY_ICON = "bx bx-empty";
+
/** What in a row takes focus from a press: the controls that are typed into. */
const TEXT_ENTRY = "input:not([type='checkbox'], [type='radio']), textarea, select, [contenteditable='true']";
@@ -222,8 +226,10 @@ export function FormListItem({ className, icon, iconSvg, iconClassName, value, t
menu.openSubmenu(level, undefined, e.currentTarget);
}
+ const hasOwnIcon = !!iconSvg || (!!icon && icon !== EMPTY_ICON);
if (checked) {
- icon = "bx bx-check";
+ if (hasOwnIcon) trailingIcon ??= CHECK_ICON;
+ else icon = CHECK_ICON;
}
useStaticTooltip(itemRef, TOOLTIP_CONFIG);
@@ -269,7 +275,7 @@ export function FormListItem({ className, icon, iconSvg, iconClassName, value, t
>
{/* One classless span holds the row, as the rows of a menu are laid out. */}
<span>
- {iconSvg && !checked
+ {iconSvg
? <SvgIcon svg={iconSvg} className={iconClassName} />
: icon === null ? <span /> : <Icon icon={icon} className={iconClassName} />}
{/* An element, not spaces: in a flex row, text merges with a plain title but is
diff --git a/apps/client/src/widgets/type_widgets/file/MediaPlayer.tsx b/apps/client/src/widgets/type_widgets/file/MediaPlayer.tsx
index b872760b75..19d33fefef 100644
--- a/apps/client/src/widgets/type_widgets/file/MediaPlayer.tsx
+++ b/apps/client/src/widgets/type_widgets/file/MediaPlayer.tsx
@@ -600,7 +600,7 @@ export function PlayModeButton({ mode, onSelectMode }: { mode: MediaPlayMode, on
<FormListItem
key={candidate}
icon={MEDIA_PLAY_MODE_ICONS[candidate]}
- trailingIcon={candidate === mode ? "bx bx-check" : undefined}
+ checked={candidate === mode}
onClick={() => onSelectMode(candidate)}
>
{t(MEDIA_PLAY_MODE_LABEL_KEYS[candidate])}