Skip to content

Build your personal knowledge base with Trilium Notes

fix(client): point a submenu's arrow to the end wherever it opens

Elian Doranc12c814ee099
diff --git a/apps/client/src/stylesheets/theme-next/base.css b/apps/client/src/stylesheets/theme-next/base.css
index d358a6d078..cfd75d3a38 100644
--- a/apps/client/src/stylesheets/theme-next/base.css
+++ b/apps/client/src/stylesheets/theme-next/base.css
@@ -254,13 +254,6 @@ body.desktop .dropdown-item.dropdown-submenu .dropdown-toggle,
}
}
-/* Each menu level holds its rows in its own `.tn-menu-scroll`; submenu layers are outside it. */
-body.desktop .tn-menu-scroll:has(.dropdown-submenu.dropstart) .dropdown-item:not(.dropdown-submenu),
-body.desktop .tn-menu-scroll:has(.dropdown-submenu.dropstart) .dropdown-item.dropdown-submenu .dropdown-toggle {
- padding-inline-end: var(--menu-item-start-padding) !important;
- padding-inline-start: var(--menu-item-end-padding) !important;
-}
-
:root .dropdown-item:focus-visible {
outline: 2px solid var(--input-focus-outline-color) !important;
background-color: transparent;
@@ -339,7 +332,7 @@ html body .dropdown-item[disabled] {
/* Menu item arrow */
body.mobile .dropdown-submenu .dropdown-toggle::after,
-body.desktop .dropdown-submenu:not(.dropstart) .dropdown-toggle::after {
+body.desktop .dropdown-submenu .dropdown-toggle::after {
content: "\ed3b" !important;
position: absolute;
display: flex !important;
@@ -355,33 +348,9 @@ body.desktop .dropdown-submenu:not(.dropstart) .dropdown-toggle::after {
color: var(--menu-item-arrow-color) !important;
}
-body.mobile .dropdown-submenu.dropstart .dropdown-toggle::before {
- content: unset;
-}
-
-body.desktop .dropdown-submenu.dropstart .dropdown-toggle::before {
+/* Right to left, the end side is the left, so the arrow points the other way. */
+body.desktop[dir=rtl] .dropdown-submenu .dropdown-toggle::after {
content: "\ea4d" !important;
- position: absolute;
- display: flex !important;
- align-items: center;
- justify-content: center;
- top: 0;
- inset-inline-start: 0;
- margin: unset !important;
- border: unset !important;
- padding: 0 4px;
- font-family: boxicons;
- font-size: 1.2em;
- color: var(--menu-item-arrow-color) !important;
-}
-
-/* Right to left, the end side is the left, so both arrows point the other way. */
-body.desktop[dir=rtl] .dropdown-submenu:not(.dropstart) .dropdown-toggle::after {
- content: "\ea4d" !important;
-}
-
-body.desktop[dir=rtl] .dropdown-submenu.dropstart .dropdown-toggle::before {
- content: "\ed3b" !important;
}
/* Menu item group heading */
diff --git a/apps/client/src/widgets/react/FormList.tsx b/apps/client/src/widgets/react/FormList.tsx
index ef09ba3892..9823e189fc 100644
--- a/apps/client/src/widgets/react/FormList.tsx
+++ b/apps/client/src/widgets/react/FormList.tsx
@@ -422,7 +422,7 @@ function MenuSubmenu({ menu, icon, iconSvg, title, children, onDropdownToggleCli
menu.registerRow(id, element ? { level, element, custom: false, disabled: !!disabled, hasSubmenu: true, select } : undefined);
}}
className={clsx("dropdown-item dropdown-submenu", open && "submenu-open", isActive && "tn-menu-active",
- menu.dropStart[level] && "dropstart", disabled && "disabled", className)}
+ disabled && "disabled", className)}
role="menuitem"
aria-disabled={disabled || undefined}
aria-haspopup="menu"
diff --git a/apps/client/src/widgets/react/Menu.spec.tsx b/apps/client/src/widgets/react/Menu.spec.tsx
index 296a49f758..2071b17277 100644
--- a/apps/client/src/widgets/react/Menu.spec.tsx
+++ b/apps/client/src/widgets/react/Menu.spec.tsx
@@ -239,7 +239,7 @@ describe("Menu with declared rows", () => {
expect(activeTitle(menu)).toBe("Copy");
});
- it("opens submenus towards the start, arrows too, when the end has no room", async () => {
+ it("opens submenus towards the start when the end has no room, arrows still at the end", async () => {
// The menus and their rows are 120px wide, at the right edge of a 1024px viewport.
vi.spyOn(document.documentElement, "clientWidth", "get").mockReturnValue(1024);
vi.spyOn(document.documentElement, "clientHeight", "get").mockReturnValue(768);
@@ -252,7 +252,6 @@ describe("Menu with declared rows", () => {
try {
const { menu } = renderMenu();
const advanced = rowTitled("Advanced");
- await vi.waitFor(() => expect(advanced.classList).toContain("dropstart"));
advanced.dispatchEvent(new PointerEvent("pointerenter"));
await vi.waitFor(() => expect(layers(menu)).toHaveLength(1));
@@ -260,7 +259,8 @@ describe("Menu with declared rows", () => {
// Next to the row's left edge (900px), not its right edge (1020px). happy-dom gives the
// layer no width.
await vi.waitFor(() => expect(parseFloat(layer?.style.left ?? "")).toBeLessThan(910));
- expect(advanced.classList).toContain("dropstart");
+ // The arrow marks a submenu, as in the operating system's menus, wherever it opens.
+ expect(advanced.classList).not.toContain("dropstart");
} finally {
vi.restoreAllMocks();
}
diff --git a/apps/client/src/widgets/react/menu_context.ts b/apps/client/src/widgets/react/menu_context.ts
index 12d3316029..985851c9a4 100644
--- a/apps/client/src/widgets/react/menu_context.ts
+++ b/apps/client/src/widgets/react/menu_context.ts
@@ -56,8 +56,8 @@ export interface MenuContextValue {
/** Whether the keys moved the menu since the pointer last did. */
keyboardDriven: boolean;
/**
- * Whether the submenus of each level's rows open towards the start, indexed by level. The rows
- * of a level that does carry `.dropstart`, which points their arrow that way.
+ * Whether the submenus of each level's rows open towards the start, indexed by level. Only the
+ * placement follows it; a row's arrow points to the end, as in the operating system's menus.
*/
dropStart: boolean[];
/** Records the side the submenus of `level`'s rows open on. */