From fb7335624fd14563d0a73b99eb02f3c729585c10 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Tue, 30 Aug 2022 19:53:09 +0200 Subject: [PATCH] Do not render fallback anchor if there is already a prop-derived anchor --- packages/components/src/popover/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/components/src/popover/index.js b/packages/components/src/popover/index.js index 1742ae16aabfd9..daf53d2139592a 100644 --- a/packages/components/src/popover/index.js +++ b/packages/components/src/popover/index.js @@ -215,6 +215,7 @@ const Popover = ( const arrowRef = useRef( null ); + const [ referenceElement, setReferenceElement ] = useState(); const [ fallbackReferenceElement, setFallbackReferenceElement ] = useState(); const [ referenceOwnerDocument, setReferenceOwnerDocument ] = useState(); @@ -377,6 +378,7 @@ const Popover = ( referenceCallbackRef( resultingReferenceElement ); + setReferenceElement( resultingReferenceElement ); setReferenceOwnerDocument( resultingReferenceOwnerDoc ); }, [ anchor, @@ -500,7 +502,7 @@ const Popover = ( content = { content }; } - if ( anchorRef || anchorRect ) { + if ( referenceElement && referenceElement !== fallbackReferenceElement ) { return content; }