Skip to content

Commit

Permalink
Initialize the content size used in Popover computation (#23279)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Jun 18, 2020
1 parent 881b7f2 commit 9f44f9f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/components/src/popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ const Popover = ( {
const slot = useSlot( __unstableSlotName );
const isExpanded = expandOnMobile && isMobileViewport;
const [ containerResizeListener, contentSize ] = useResizeObserver();

noArrow = isExpanded || noArrow;

useEffect( () => {
Expand Down Expand Up @@ -330,6 +329,10 @@ const Popover = ( {
)?.parentNode;
}

const usedContentSize = ! contentSize.height
? contentRef.current.getBoundingClientRect()
: contentSize;

const {
popoverTop,
popoverLeft,
Expand All @@ -339,7 +342,7 @@ const Popover = ( {
contentWidth,
} = computePopoverPosition(
anchor,
contentSize,
usedContentSize,
position,
__unstableSticky,
containerRef.current,
Expand Down
3 changes: 3 additions & 0 deletions packages/e2e-test-utils/src/transform-block-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export async function transformBlockTo( name ) {
visible: true,
} );
await switcherToggle.click();
await page.waitForSelector( '.block-editor-block-switcher__container', {
visible: true,
} );

// Find the block button option within the switcher popover.
const xpath = `//*[contains(@class, "block-editor-block-switcher__popover")]//button[.='${ name }']`;
Expand Down

0 comments on commit 9f44f9f

Please sign in to comment.