@topconsultnpm/sdkui-react 6.20.0-dev1.63 → 6.20.0-dev1.64
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.
|
@@ -20,41 +20,6 @@ const TMContextMenu = ({ items, trigger = 'right', children, target, externalCon
|
|
|
20
20
|
const longPressTimeoutRef = useRef(null);
|
|
21
21
|
const touchStartPos = useRef(null);
|
|
22
22
|
const { openLeft, openUp, isCalculated } = useMenuPosition(menuRef, menuState.position);
|
|
23
|
-
// Adjust menu position on mobile to prevent overflow
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (!isMobile || !menuState.visible || !menuRef.current)
|
|
26
|
-
return;
|
|
27
|
-
const adjustPosition = () => {
|
|
28
|
-
const menuElement = menuRef.current;
|
|
29
|
-
if (!menuElement)
|
|
30
|
-
return;
|
|
31
|
-
const menuRect = menuElement.getBoundingClientRect();
|
|
32
|
-
const viewportHeight = window.innerHeight;
|
|
33
|
-
const currentY = menuState.position.y;
|
|
34
|
-
// Check if menu overflows bottom of viewport
|
|
35
|
-
const menuBottom = currentY + menuRect.height;
|
|
36
|
-
const overflowBottom = menuBottom - viewportHeight;
|
|
37
|
-
if (overflowBottom > 0) {
|
|
38
|
-
// Calculate new Y position to fit menu in viewport
|
|
39
|
-
let newY = currentY - overflowBottom - 10; // 10px padding from edge
|
|
40
|
-
// Ensure menu doesn't go above viewport top
|
|
41
|
-
if (newY < 10) {
|
|
42
|
-
newY = 10;
|
|
43
|
-
}
|
|
44
|
-
// Only update if position actually changed
|
|
45
|
-
if (newY !== currentY) {
|
|
46
|
-
setMenuState(prev => ({
|
|
47
|
-
...prev,
|
|
48
|
-
position: { ...prev.position, y: newY }
|
|
49
|
-
}));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
// Wait for menu to render before adjusting
|
|
54
|
-
requestAnimationFrame(() => {
|
|
55
|
-
requestAnimationFrame(adjustPosition);
|
|
56
|
-
});
|
|
57
|
-
}, [isMobile, menuState.visible, menuState.position.y]);
|
|
58
23
|
const handleClose = () => {
|
|
59
24
|
if (externalControl) {
|
|
60
25
|
externalControl.onClose();
|