diff --git a/apps/client/src/menus/context_menu.ts b/apps/client/src/menus/context_menu.ts index a0e6d5cb5..c9ab89e3f 100644 --- a/apps/client/src/menus/context_menu.ts +++ b/apps/client/src/menus/context_menu.ts @@ -156,15 +156,32 @@ class ContextMenu { } addItems($parent: JQuery, items: MenuItem[]) { - for (const item of items) { + let $group = $parent; + let shouldResetGroup = false; // If true, the next item will be the last one from the group + + for (let index = 0; index < items.length; index++) { + const item = items[index]; if (!item) { continue; } + // If the next item is a separator or header, create a new group to avoid column breaks + // before and after the seaparator/header. + // This is a workaround for Firefox not supporting break-after: avoid on columns. + const nextItem = (index < items.length - 1) ? items[index + 1] : null; + if (!shouldResetGroup && nextItem && "kind" in nextItem) { + if (nextItem.kind === "separator" || nextItem.kind === "header") { + $group = $("