@@ -26,7 +26,12 @@ export interface ModalOverlayProps extends AriaModalOverlayProps, OverlayTrigger
2626 /**
2727 * Whether the modal is currently performing an exit animation.
2828 */
29- isExiting ?: boolean
29+ isExiting ?: boolean ,
30+ /**
31+ * The container element in which the overlay portal will be placed. This may have unknown behavior depending on where it is portalled to.
32+ * @default document.body
33+ */
34+ UNSTABLE_portalContainer ?: Element
3035}
3136
3237interface InternalModalContextValue {
@@ -72,6 +77,7 @@ function Modal(props: ModalOverlayProps, ref: ForwardedRef<HTMLDivElement>) {
7277 children,
7378 isEntering,
7479 isExiting,
80+ UNSTABLE_portalContainer,
7581 ...otherProps
7682 } = props ;
7783
@@ -83,7 +89,8 @@ function Modal(props: ModalOverlayProps, ref: ForwardedRef<HTMLDivElement>) {
8389 defaultOpen = { defaultOpen }
8490 onOpenChange = { onOpenChange }
8591 isEntering = { isEntering }
86- isExiting = { isExiting } >
92+ isExiting = { isExiting }
93+ UNSTABLE_portalContainer = { UNSTABLE_portalContainer } >
8794 < ModalContent { ...otherProps } modalRef = { ref } >
8895 { children }
8996 </ ModalContent >
@@ -136,7 +143,7 @@ function ModalOverlayWithForwardRef(props: ModalOverlayProps, ref: ForwardedRef<
136143 */
137144export const ModalOverlay = /*#__PURE__*/ ( forwardRef as forwardRefType ) ( ModalOverlayWithForwardRef ) ;
138145
139- function ModalOverlayInner ( props : ModalOverlayInnerProps ) {
146+ function ModalOverlayInner ( { UNSTABLE_portalContainer , ... props } : ModalOverlayInnerProps ) {
140147 let modalRef = props . modalRef ;
141148 let { state} = props ;
142149 let { modalProps, underlayProps} = useModalOverlay ( props , state , modalRef ) ;
@@ -159,7 +166,7 @@ function ModalOverlayInner(props: ModalOverlayInnerProps) {
159166 } ;
160167
161168 return (
162- < Overlay isExiting = { props . isExiting } >
169+ < Overlay isExiting = { props . isExiting } portalContainer = { UNSTABLE_portalContainer } >
163170 < div
164171 { ...mergeProps ( filterDOMProps ( props as any ) , underlayProps ) }
165172 { ...renderProps }
0 commit comments