@@ -181,7 +181,7 @@ interface PopoverTriggerProps {
181181}
182182
183183export const PopoverTrigger = React . forwardRef < HTMLElement , React . HTMLProps < HTMLElement > & PopoverTriggerProps > (
184- function PopoverTrigger ( { children, asChild = false , ...props } , propRef ) {
184+ function PopoverTrigger ( { children, asChild = false , triggerClass , ...props } , propRef ) {
185185 const context = usePopoverContext ( ) ;
186186 const childrenRef = ( children as any ) . ref ;
187187 const ref = useMergeRefs ( [ context . refs . setReference , propRef , childrenRef ] ) ;
@@ -204,7 +204,7 @@ export const PopoverTrigger = React.forwardRef<HTMLElement, React.HTMLProps<HTML
204204 } ;
205205
206206 if ( asChild ) {
207- return < div className = { props . triggerClass } > { getClonedElement ( ) } </ div > ;
207+ return < div className = { triggerClass } > { getClonedElement ( ) } </ div > ;
208208 }
209209
210210 return (
@@ -232,33 +232,36 @@ export const PopoverContent = React.forwardRef<HTMLDivElement, React.HTMLProps<H
232232
233233 const { isMounted, styles, portalRoot, appendToBody } = context ;
234234
235- const boundaryElement = appendToBody && document ? document . body : portalRoot ;
235+ const boundaryElement = appendToBody !== false && document ? document . body : portalRoot ;
236236
237237 const isValidPosition = context . x !== 0 && context . y !== 0 ;
238238 const showVisibility =
239239 context . middlewareData . hide ?. referenceHidden || context . middlewareData . hide ?. escaped || ! isValidPosition ;
240240
241- return (
242- < FloatingPortal root = { boundaryElement } >
243- { isMounted && (
244- // <FloatingFocusManager context={floatingContext}
245- // // modal={context.modal}
246- // initialFocus={-1}>
247- < div
248- ref = { ref }
249- style = { {
250- ...context . floatingStyles ,
251- ...style ,
252- visibility : showVisibility ? 'hidden' : 'visible' ,
253- } }
254- { ...context . getFloatingProps ( props ) }
255- >
256- < div style = { styles } > { props . children } </ div >
257- </ div >
258- // </FloatingFocusManager>
259- ) }
260- </ FloatingPortal >
241+ const content = isMounted && (
242+ // <FloatingFocusManager context={floatingContext}
243+ // // modal={context.modal}
244+ // initialFocus={-1}>
245+ < div
246+ ref = { ref }
247+ style = { {
248+ ...context . floatingStyles ,
249+ ...style ,
250+ visibility : showVisibility ? 'hidden' : 'visible' ,
251+ } }
252+ { ...context . getFloatingProps ( props ) }
253+ >
254+ < div style = { styles } > { props . children } </ div >
255+ </ div >
256+ // </FloatingFocusManager>
261257 ) ;
258+
259+ // If appendToBody is explicitly false and no portalRoot is provided, don't use portal
260+ if ( appendToBody === false && ! portalRoot ) {
261+ return content ;
262+ }
263+
264+ return < FloatingPortal root = { boundaryElement } > { content } </ FloatingPortal > ;
262265} ) ;
263266
264267export default PopperWrapper ;
0 commit comments