MCPcopy Index your code
hub / github.com/adobe/react-spectrum / useModalOverlay

Function useModalOverlay

packages/react-aria/src/overlays/useModalOverlay.ts:51–81  ·  view source on GitHub ↗
(
  props: AriaModalOverlayProps,
  state: OverlayTriggerState,
  ref: RefObject<HTMLElement | null>
)

Source from the content-addressed store, hash-verified

49 * A modal is an overlay element which blocks interaction with elements outside it.
50 */
51export function useModalOverlay(
52 props: AriaModalOverlayProps,
53 state: OverlayTriggerState,
54 ref: RefObject<HTMLElement | null>
55): ModalOverlayAria {
56 let {overlayProps, underlayProps} = useOverlay(
57 {
58 ...props,
59 isOpen: state.isOpen,
60 onClose: state.close
61 },
62 ref
63 );
64
65 usePreventScroll({
66 isDisabled: !state.isOpen
67 });
68
69 useOverlayFocusContain();
70
71 useEffect(() => {
72 if (state.isOpen && ref.current) {
73 return ariaHideOutside([ref.current], {shouldUseInert: true});
74 }
75 }, [state.isOpen, ref]);
76
77 return {
78 modalProps: mergeProps(overlayProps),
79 underlayProps
80 };
81}

Callers 5

ExampleFunction · 0.90
ModalOverlayInnerFunction · 0.90
Modal.tsxFile · 0.90
Tray.tsxFile · 0.90
ToastContainerFunction · 0.90

Calls 5

useOverlayFunction · 0.90
usePreventScrollFunction · 0.90
useOverlayFocusContainFunction · 0.90
ariaHideOutsideFunction · 0.90
mergePropsFunction · 0.90

Tested by 1

ExampleFunction · 0.72