Skip to content

Commit

Permalink
Popover: don't render fallback anchor if anchorRef is defined (#19308)
Browse files Browse the repository at this point in the history
* Popover: don't render fallback anchor if anchorRef is defined

* include anchorRect
  • Loading branch information
ellatrix authored Dec 23, 2019
1 parent cb150a2 commit a94c854
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/components/src/popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ const Popover = ( {
onKeyDown={ maybeClose }
ref={ containerRef }
>
{ isExpanded && <ScrollLock /> }
{ isExpanded && (
<div className="components-popover__header">
<span className="components-popover__header-title">
Expand Down Expand Up @@ -493,10 +494,13 @@ const Popover = ( {
content = <Fill name={ __unstableSlotName }>{ content }</Fill>;
}

if ( anchorRef || anchorRect ) {
return content;
}

return (
<span ref={ anchorRefFallback }>
{ content }
{ isMobileViewport && expandOnMobile && <ScrollLock /> }
</span>
);
} }
Expand Down

0 comments on commit a94c854

Please sign in to comment.