Files
wekan/client/lib/popupMenuLayout.js
T
Lauri Ojansivu e0a53728b4 Use available popup width for menu columns and card settings
Place Draggable before Minicard and Card in a three-column layout that stacks when the popup is narrow. Expand long option menus and pickers into balanced columns while preserving form layouts, search focus, popup stack navigation and permission-filtered options.

Thanks to xet7.
2026-09-27 14:03:15 +03:00

20 lines
1.4 KiB
JavaScript

// Long option menus can share columns; forms and specialized widgets keep their
// own layouts. Inspect only the active stack entry so a parent menu cannot widen
// a child form. No options or permission guards are added or removed here.
export function updatePopupMenuColumns(popup) {
const content = popup.querySelector('.content-container > .content:not(.no-height)');
const lists = content ? Array.from(content.children).filter(el => el.matches('ul.pop-over-list, ul.edit-labels-pop-over')) : [];
const count = lists.reduce((total, list) => total + list.querySelectorAll('li').length, 0);
const searchFields = 'input[type=search], input.card-members-filter, input.card-assignees-filter, input.card-identity-filter';
const hasSearch = !!content?.querySelector(searchFields);
const keepSearchLayout = hasSearch && content.classList.contains('popup-menu-columns');
const hasWidget = !!content?.querySelector(`form, input:not(${searchFields}), textarea, select, table, .palette-colors`);
const eligible = (count >= 8 || keepSearchLayout) && !hasWidget;
for (const entry of popup.querySelectorAll('.content-container > .content')) {
const wanted = eligible && entry === content;
if (entry.classList.contains('popup-menu-columns') !== wanted) entry.classList.toggle('popup-menu-columns', wanted);
}
if (popup.classList.contains('pop-over--menu-columns') !== eligible) popup.classList.toggle('pop-over--menu-columns', eligible);
return eligible;
}