@react-aria/overlays 3.15.0 → 3.17.0

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/module.js CHANGED
@@ -67,7 +67,7 @@ const $edcf132a9284368a$var$TOTAL_SIZE = {
67
67
  };
68
68
  const $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE = {};
69
69
  // @ts-ignore
70
- let $edcf132a9284368a$var$visualViewport = typeof window !== "undefined" && window.visualViewport;
70
+ let $edcf132a9284368a$var$visualViewport = typeof document !== "undefined" && window.visualViewport;
71
71
  function $edcf132a9284368a$var$getContainerDimensions(containerNode) {
72
72
  let width = 0, height = 0, totalWidth = 0, totalHeight = 0, top = 0, left = 0;
73
73
  let scroll = {};
@@ -107,7 +107,9 @@ function $edcf132a9284368a$var$getScroll(node) {
107
107
  };
108
108
  }
109
109
  function $edcf132a9284368a$var$getDelta(axis, offset, size, containerDimensions, padding) {
110
- let containerScroll = containerDimensions.scroll[axis];
110
+ let root = document.scrollingElement || document.documentElement;
111
+ let isScrollPrevented = window.getComputedStyle(root).overflow === "hidden";
112
+ let containerScroll = isScrollPrevented ? 0 : containerDimensions.scroll[axis];
111
113
  let containerHeight = containerDimensions[$edcf132a9284368a$var$AXIS_SIZE[axis]];
112
114
  let startEdgeOffset = offset - padding - containerScroll;
113
115
  let endEdgeOffset = offset + padding - containerScroll + size;
@@ -236,7 +238,7 @@ function $edcf132a9284368a$export$6839422d1f33cee9(placementInput, childOffset,
236
238
  };
237
239
  }
238
240
  function $edcf132a9284368a$export$b3ceb0cbf1056d98(opts) {
239
- let { placement: placement , targetNode: targetNode , overlayNode: overlayNode , scrollNode: scrollNode , padding: padding , shouldFlip: shouldFlip , boundaryElement: boundaryElement , offset: offset , crossOffset: crossOffset , maxHeight: maxHeight , arrowSize: arrowSize , arrowBoundaryOffset: arrowBoundaryOffset = 0 } = opts;
241
+ let { placement: placement , targetNode: targetNode , overlayNode: overlayNode , scrollNode: scrollNode , padding: padding , shouldFlip: shouldFlip , boundaryElement: boundaryElement , offset: offset , crossOffset: crossOffset , maxHeight: maxHeight , arrowSize: arrowSize = 0 , arrowBoundaryOffset: arrowBoundaryOffset = 0 } = opts;
240
242
  let container = overlayNode instanceof HTMLElement ? $edcf132a9284368a$var$getContainingBlock(overlayNode) : document.documentElement;
241
243
  let isViewportContainer = container === document.documentElement;
242
244
  const containerPositionStyle = window.getComputedStyle(container).position;
@@ -361,7 +363,7 @@ function $dd149f63282afbbf$export$18fc8428861184da(opts) {
361
363
 
362
364
 
363
365
  // @ts-ignore
364
- let $2a41e45df1593e64$var$visualViewport = typeof window !== "undefined" && window.visualViewport;
366
+ let $2a41e45df1593e64$var$visualViewport = typeof document !== "undefined" && window.visualViewport;
365
367
  function $2a41e45df1593e64$export$d39e1813b3bdd0e1(props) {
366
368
  let { direction: direction } = (0, $k7QOs$useLocale)();
367
369
  let { arrowSize: arrowSize = 0 , targetRef: targetRef , overlayRef: overlayRef , scrollRef: scrollRef = overlayRef , placement: placement = "bottom" , containerPadding: containerPadding = 12 , shouldFlip: shouldFlip = true , boundaryElement: boundaryElement = typeof document !== "undefined" ? document.body : null , offset: offset = 0 , crossOffset: crossOffset = 0 , shouldUpdatePosition: shouldUpdatePosition = true , isOpen: isOpen = true , onClose: onClose , maxHeight: maxHeight , arrowBoundaryOffset: arrowBoundaryOffset = 0 } = props;
@@ -469,6 +471,8 @@ function $2a41e45df1593e64$export$d39e1813b3bdd0e1(props) {
469
471
  },
470
472
  placement: position.placement,
471
473
  arrowProps: {
474
+ "aria-hidden": "true",
475
+ role: "presentation",
472
476
  style: {
473
477
  left: position.arrowOffsetLeft,
474
478
  top: position.arrowOffsetTop
@@ -558,10 +562,16 @@ function $a11501f3d1d39e6c$export$ea8f71083e90600f(props, ref) {
558
562
  let { focusWithinProps: focusWithinProps } = (0, $k7QOs$useFocusWithin)({
559
563
  isDisabled: !shouldCloseOnBlur,
560
564
  onBlurWithin: (e)=>{
565
+ // Do not close if relatedTarget is null, which means focus is lost to the body.
566
+ // That can happen when switching tabs, or due to a VoiceOver/Chrome bug with Control+Option+Arrow navigation.
567
+ // Clicking on the body to close the overlay should already be handled by useInteractOutside.
568
+ // https://github.com/adobe/react-spectrum/issues/4130
569
+ // https://github.com/adobe/react-spectrum/issues/4922
570
+ //
561
571
  // If focus is moving into a child focus scope (e.g. menu inside a dialog),
562
572
  // do not close the outer overlay. At this point, the active scope should
563
573
  // still be the outer overlay, since blur events run before focus.
564
- if (e.relatedTarget && (0, $k7QOs$isElementInChildOfActiveScope)(e.relatedTarget)) return;
574
+ if (!e.relatedTarget || (0, $k7QOs$isElementInChildOfActiveScope)(e.relatedTarget)) return;
565
575
  if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside(e.relatedTarget)) onClose();
566
576
  }
567
577
  });
@@ -636,7 +646,7 @@ function $628037886ba31236$export$f9d5c8beee7d008d(props, state, ref) {
636
646
  * governing permissions and limitations under the License.
637
647
  */
638
648
  // @ts-ignore
639
- const $49c51c25361d4cd2$var$visualViewport = typeof window !== "undefined" && window.visualViewport;
649
+ const $49c51c25361d4cd2$var$visualViewport = typeof document !== "undefined" && window.visualViewport;
640
650
  // HTML input types that do not cause the software keyboard to appear.
641
651
  const $49c51c25361d4cd2$var$nonTextInputTypes = new Set([
642
652
  "checkbox",
@@ -1396,7 +1406,7 @@ function $f2f8a6077418541e$export$542a6fd13ac93354(props, state) {
1396
1406
  const $337b884510726a0d$export$a2200b96afd16271 = /*#__PURE__*/ (0, $k7QOs$react).createContext(null);
1397
1407
  function $337b884510726a0d$export$c6fdb837b070b4ff(props) {
1398
1408
  let isSSR = (0, $k7QOs$useIsSSR)();
1399
- let { portalContainer: portalContainer = isSSR ? null : document.body } = props;
1409
+ let { portalContainer: portalContainer = isSSR ? null : document.body , isExiting: isExiting } = props;
1400
1410
  let [contain, setContain] = (0, $k7QOs$useState)(false);
1401
1411
  let contextValue = (0, $k7QOs$useMemo)(()=>({
1402
1412
  contain: contain,
@@ -1411,7 +1421,7 @@ function $337b884510726a0d$export$c6fdb837b070b4ff(props) {
1411
1421
  value: contextValue
1412
1422
  }, /*#__PURE__*/ (0, $k7QOs$react).createElement((0, $k7QOs$FocusScope), {
1413
1423
  restoreFocus: true,
1414
- contain: contain
1424
+ contain: contain && !isExiting
1415
1425
  }, props.children));
1416
1426
  else contents = /*#__PURE__*/ (0, $k7QOs$react).createElement($337b884510726a0d$export$a2200b96afd16271.Provider, {
1417
1427
  value: contextValue