@topconsultnpm/sdkui-react 6.21.0-dev4.5 → 6.21.0-dev4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -395,26 +395,31 @@ const TMContextMenu = ({ items, trigger = 'right', children, target, externalCon
|
|
|
395
395
|
];
|
|
396
396
|
});
|
|
397
397
|
};
|
|
398
|
-
// Caps overflowing submenus with max-height + scroll so every item stays reachable.
|
|
399
398
|
useLayoutEffect(() => {
|
|
400
399
|
if (hoveredSubmenus.length === 0)
|
|
401
400
|
return;
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
401
|
+
const capSubmenus = () => {
|
|
402
|
+
const padding = 8;
|
|
403
|
+
const submenus = document.querySelectorAll('[data-submenu="true"]');
|
|
404
|
+
submenus.forEach(el => {
|
|
405
|
+
el.style.maxHeight = '';
|
|
406
|
+
el.style.overflowY = '';
|
|
407
|
+
el.style.overflowX = '';
|
|
408
|
+
const rect = el.getBoundingClientRect();
|
|
409
|
+
const opensUp = el.dataset.openUp === 'true';
|
|
410
|
+
const available = opensUp
|
|
411
|
+
? rect.bottom - padding
|
|
412
|
+
: window.innerHeight - rect.top - padding;
|
|
413
|
+
if (rect.height <= available)
|
|
414
|
+
return;
|
|
415
|
+
el.style.maxHeight = `${Math.max(80, available)}px`;
|
|
416
|
+
el.style.overflowY = 'auto';
|
|
417
|
+
el.style.overflowX = 'hidden';
|
|
418
|
+
});
|
|
419
|
+
};
|
|
420
|
+
capSubmenus();
|
|
421
|
+
window.addEventListener('resize', capSubmenus);
|
|
422
|
+
return () => window.removeEventListener('resize', capSubmenus);
|
|
418
423
|
}, [hoveredSubmenus]);
|
|
419
424
|
const handleMouseLeave = (depth = 0) => {
|
|
420
425
|
if (isMobile)
|
|
@@ -495,6 +500,6 @@ const TMContextMenu = ({ items, trigger = 'right', children, target, externalCon
|
|
|
495
500
|
// display: 'inline-block',
|
|
496
501
|
WebkitTouchCallout: isIOS ? 'none' : undefined,
|
|
497
502
|
WebkitUserSelect: isIOS ? 'none' : undefined,
|
|
498
|
-
}, children: children })), menuState.visible && createPortal(_jsxs(_Fragment, { children: [_jsxs(S.MenuContainer, { ref: menuRef, "$x": menuState.position.x, "$y": menuState.position.y, "$openLeft": openLeft, "$openUp": openUp, "$isPositioned": isCalculated, "$externalControl": !!externalControl, "$needsScroll": needsScroll, "$maxHeight": maxHeight, children: [isMobile && menuState.parentNames.length > 0 && (_jsxs(S.MobileMenuHeader, { children: [_jsx(S.BackButton, { onClick: handleBack, "aria-label": "Go back", children: _jsx(IconArrowLeft, {}) }), _jsx(S.HeaderTitle, { children: currentParentName })] })), renderMenuItems(currentMenu, 0)] }), !isMobile && hoveredSubmenus.map((submenu, idx) => (_jsx(S.Submenu, { "$parentRect": submenu.parentRect, "$openUp": submenu.openUp, "data-submenu": "true", onMouseEnter: handleSubmenuMouseEnter, onMouseLeave: () => handleMouseLeave(submenu.depth), children: renderMenuItems(submenu.items, submenu.depth) }, `submenu-${submenu.depth}-${idx}`)))] }), document.body)] }));
|
|
503
|
+
}, children: children })), menuState.visible && createPortal(_jsxs(_Fragment, { children: [_jsxs(S.MenuContainer, { ref: menuRef, "$x": menuState.position.x, "$y": menuState.position.y, "$openLeft": openLeft, "$openUp": openUp, "$isPositioned": isCalculated, "$externalControl": !!externalControl, "$needsScroll": needsScroll, "$maxHeight": maxHeight, children: [isMobile && menuState.parentNames.length > 0 && (_jsxs(S.MobileMenuHeader, { children: [_jsx(S.BackButton, { onClick: handleBack, "aria-label": "Go back", children: _jsx(IconArrowLeft, {}) }), _jsx(S.HeaderTitle, { children: currentParentName })] })), renderMenuItems(currentMenu, 0)] }), !isMobile && hoveredSubmenus.map((submenu, idx) => (_jsx(S.Submenu, { "$parentRect": submenu.parentRect, "$openUp": submenu.openUp, "data-submenu": "true", "data-open-up": submenu.openUp ? 'true' : 'false', onMouseEnter: handleSubmenuMouseEnter, onMouseLeave: () => handleMouseLeave(submenu.depth), children: renderMenuItems(submenu.items, submenu.depth) }, `submenu-${submenu.depth}-${idx}`)))] }), document.body)] }));
|
|
499
504
|
};
|
|
500
505
|
export default TMContextMenu;
|