client/menus: improve the multicolumn breaking strategy

This commit is contained in:
Adorian Doran 2025-09-20 03:25:16 +03:00
parent 34338a795f
commit 053a84483c

View File

@ -2,6 +2,7 @@ import { KeyboardActionNames } from "@triliumnext/commons";
import keyboardActionService, { getActionSync } from "../services/keyboard_actions.js"; import keyboardActionService, { getActionSync } from "../services/keyboard_actions.js";
import note_tooltip from "../services/note_tooltip.js"; import note_tooltip from "../services/note_tooltip.js";
import utils from "../services/utils.js"; import utils from "../services/utils.js";
import { should } from "vitest";
export interface ContextMenuOptions<T> { export interface ContextMenuOptions<T> {
x: number; x: number;
@ -170,9 +171,13 @@ class ContextMenu {
// This is a workaround for Firefox not supporting break-after: avoid on columns. // This is a workaround for Firefox not supporting break-after: avoid on columns.
const nextItem = (index < items.length - 1) ? items[index + 1] : null; const nextItem = (index < items.length - 1) ? items[index + 1] : null;
if (multicolumn && nextItem && "kind" in nextItem) { if (multicolumn && nextItem && "kind" in nextItem) {
if (!shouldResetGroup && (nextItem.kind === "separator" || nextItem.kind === "header")) { if (nextItem.kind === "separator" || nextItem.kind === "header") {
if (!shouldResetGroup) {
$group = $("<div class='dropdown-no-break'>"); $group = $("<div class='dropdown-no-break'>");
$parent.append($group); $parent.append($group);
} else {
shouldResetGroup = false; // Continue the current group
}
} }
} }