@dloizides/ui-layout 1.40.1 → 1.40.2

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/dist/index.js CHANGED
@@ -382,14 +382,25 @@ var StickyPreview = ({
382
382
  )
383
383
  ] });
384
384
  };
385
+ var ESCAPE_KEY = "Escape";
386
+ var OPEN_MENU_SELECTOR = '[aria-expanded="true"][aria-haspopup],[aria-expanded="true"][role="combobox"],[role="menu"],[role="listbox"]';
387
+ function isInsideOpenMenu(target) {
388
+ return target instanceof Element && target.closest(OPEN_MENU_SELECTOR) !== null;
389
+ }
385
390
  function useEscapeKey(enabled, onClose) {
391
+ const isEscapeForMenu = React14.useRef(false);
386
392
  React14.useEffect(() => {
387
393
  if (reactNative.Platform.OS !== "web" || !enabled) return;
394
+ const onKeyDownCapture = (event) => {
395
+ if (event.key === ESCAPE_KEY) isEscapeForMenu.current = isInsideOpenMenu(event.target);
396
+ };
388
397
  const onKeyDown = (event) => {
389
- if (event.key === "Escape") onClose();
398
+ if (event.key === ESCAPE_KEY && !isEscapeForMenu.current) onClose();
390
399
  };
400
+ document.addEventListener("keydown", onKeyDownCapture, true);
391
401
  document.addEventListener("keydown", onKeyDown);
392
402
  return () => {
403
+ document.removeEventListener("keydown", onKeyDownCapture, true);
393
404
  document.removeEventListener("keydown", onKeyDown);
394
405
  };
395
406
  }, [enabled, onClose]);
@@ -1872,7 +1883,8 @@ var SideSheet = ({
1872
1883
  useFocusTrap(sheetRef, visible && panel.mounted, initialFocusTestID);
1873
1884
  useEscapeKey(visible, onClose);
1874
1885
  useScrollLock(visible);
1875
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: panel.mounted || backdrop.mounted, onRequestClose: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles16.root, children: [
1886
+ const hardwareBackClose = reactNative.Platform.OS === "web" ? void 0 : onClose;
1887
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: panel.mounted || backdrop.mounted, onRequestClose: hardwareBackClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles16.root, children: [
1876
1888
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [reactNative.StyleSheet.absoluteFill, styles16.scrim, { opacity: backdrop.style.opacity }] }),
1877
1889
  /* @__PURE__ */ jsxRuntime.jsx(
1878
1890
  reactNative.Pressable,