@xsolla/xui-context-menu 0.185.6 → 0.186.1

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.
package/web/index.js CHANGED
@@ -440,6 +440,7 @@ var OptionCell = ({
440
440
  themeProductContext
441
441
  });
442
442
  const theme = rawTheme;
443
+ const overlayLayer = (0, import_xui_core.useOverlayLayer)();
443
444
  const ctx = useContextMenu();
444
445
  const size = propSize ?? ctx?.size ?? "md";
445
446
  const sizing = theme.sizing.contextMenu(size);
@@ -802,7 +803,9 @@ var OptionCell = ({
802
803
  position: "fixed",
803
804
  top: submenuPos.top,
804
805
  left: submenuPos.left,
805
- zIndex: 2e3
806
+ // Same band as the parent menu; the submenu portal mounts later in
807
+ // the DOM so it paints above it (holds for arbitrary nesting depth).
808
+ zIndex: overlayLayer + import_xui_core.LAYER_OFFSET.menu
806
809
  },
807
810
  children: submenu
808
811
  }
@@ -1457,6 +1460,9 @@ var ContextMenuRoot = (0, import_react8.forwardRef)(
1457
1460
  });
1458
1461
  const xuiTheme = rawTheme;
1459
1462
  const menuId = (0, import_xui_core3.useId)();
1463
+ const overlayLayer = (0, import_xui_core3.useOverlayLayer)();
1464
+ const modalStackDepth = (0, import_xui_core3.useModalStackDepth)();
1465
+ const openModalDepthRef = (0, import_react8.useRef)(null);
1460
1466
  const [internalIsOpen, setInternalIsOpen] = (0, import_react8.useState)(false);
1461
1467
  const [activeIndex, setActiveIndex] = (0, import_react8.useState)(-1);
1462
1468
  const [cellsVersion, setCellsVersion] = (0, import_react8.useState)(0);
@@ -1562,6 +1568,19 @@ var ContextMenuRoot = (0, import_react8.forwardRef)(
1562
1568
  setActiveSubmenuId(null);
1563
1569
  }
1564
1570
  }, [isOpen]);
1571
+ (0, import_react8.useEffect)(() => {
1572
+ if (!isOpen) {
1573
+ openModalDepthRef.current = null;
1574
+ return;
1575
+ }
1576
+ if (openModalDepthRef.current === null) {
1577
+ openModalDepthRef.current = modalStackDepth;
1578
+ return;
1579
+ }
1580
+ if (modalStackDepth > openModalDepthRef.current) {
1581
+ closeMenu();
1582
+ }
1583
+ }, [isOpen, modalStackDepth, closeMenu]);
1565
1584
  (0, import_react8.useEffect)(() => {
1566
1585
  const timer = setTimeout(
1567
1586
  () => setDebouncedQuery(query),
@@ -1804,7 +1823,7 @@ var ContextMenuRoot = (0, import_react8.forwardRef)(
1804
1823
  style: {
1805
1824
  ...positionStyle,
1806
1825
  ...style,
1807
- zIndex: 1e3,
1826
+ zIndex: overlayLayer + import_xui_core3.LAYER_OFFSET.menu,
1808
1827
  boxShadow: PANEL_SHADOW,
1809
1828
  ...withArrow ? {
1810
1829
  overflow: "visible"