MCPcopy Create free account
hub / github.com/adobe/react-spectrum / ModalOverlayInner

Function ModalOverlayInner

packages/react-aria-components/src/Modal.tsx:227–289  ·  view source on GitHub ↗
({UNSTABLE_portalContainer, ...props}: ModalOverlayInnerProps)

Source from the content-addressed store, hash-verified

225);
226
227function ModalOverlayInner({UNSTABLE_portalContainer, ...props}: ModalOverlayInnerProps) {
228 let modalRef = props.modalRef;
229 let {state} = props;
230 let {modalProps, underlayProps} = useModalOverlay(props, state, modalRef);
231
232 let entering = useEnterAnimation(props.overlayRef) || props.isEntering || false;
233 let renderProps = useRenderProps({
234 ...props,
235 defaultClassName: 'react-aria-ModalOverlay',
236 values: {
237 isEntering: entering,
238 isExiting: props.isExiting,
239 state
240 }
241 });
242
243 let viewport = useViewportSize();
244 let pageWidth: number | undefined = undefined;
245 let pageHeight: number | undefined = undefined;
246 if (typeof document !== 'undefined') {
247 let scrollingElement = isScrollable(document.body)
248 ? document.body
249 : document.scrollingElement || document.documentElement;
250 // Prevent Firefox from adding scrollbars when the page has a fractional width/height.
251 let fractionalWidthDifference = scrollingElement.getBoundingClientRect().width % 1;
252 let fractionalHeightDifference = scrollingElement.getBoundingClientRect().height % 1;
253 pageWidth = scrollingElement.scrollWidth - fractionalWidthDifference;
254 pageHeight = scrollingElement.scrollHeight - fractionalHeightDifference;
255 }
256
257 let style = {
258 ...renderProps.style,
259 '--visual-viewport-width': viewport.width + 'px',
260 '--visual-viewport-height': viewport.height + 'px',
261 '--page-width': pageWidth !== undefined ? pageWidth + 'px' : undefined,
262 '--page-height': pageHeight !== undefined ? pageHeight + 'px' : undefined
263 };
264
265 // oxlint-disable react/react-compiler
266 return (
267 <Overlay isExiting={props.isExiting} portalContainer={UNSTABLE_portalContainer}>
268 <dom.div
269 {...mergeProps(filterDOMProps(props, {global: true}), underlayProps)}
270 {...renderProps}
271 style={style}
272 ref={props.overlayRef}
273 data-entering={entering || undefined}
274 data-exiting={props.isExiting || undefined}>
275 <Provider
276 values={[
277 [
278 InternalModalContext,
279 {modalProps, modalRef, isExiting: props.isExiting, isDismissable: props.isDismissable}
280 ],
281 [OverlayTriggerStateContext, state]
282 ]}>
283 {renderProps.children}
284 </Provider>

Callers

nothing calls this directly

Calls 7

useModalOverlayFunction · 0.90
useEnterAnimationFunction · 0.90
useRenderPropsFunction · 0.90
useViewportSizeFunction · 0.90
isScrollableFunction · 0.90
mergePropsFunction · 0.90
filterDOMPropsFunction · 0.90

Tested by

no test coverage detected