Skip to content

Commit

Permalink
Do not render fallback anchor if there is already a prop-derived anchor
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Aug 31, 2022
1 parent dde35cf commit fb73356
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/components/src/popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ const Popover = (

const arrowRef = useRef( null );

const [ referenceElement, setReferenceElement ] = useState();
const [ fallbackReferenceElement, setFallbackReferenceElement ] =
useState();
const [ referenceOwnerDocument, setReferenceOwnerDocument ] = useState();
Expand Down Expand Up @@ -377,6 +378,7 @@ const Popover = (

referenceCallbackRef( resultingReferenceElement );

setReferenceElement( resultingReferenceElement );
setReferenceOwnerDocument( resultingReferenceOwnerDoc );
}, [
anchor,
Expand Down Expand Up @@ -500,7 +502,7 @@ const Popover = (
content = <Fill name={ slotName }>{ content }</Fill>;
}

if ( anchorRef || anchorRect ) {
if ( referenceElement && referenceElement !== fallbackReferenceElement ) {
return content;
}

Expand Down

0 comments on commit fb73356

Please sign in to comment.