From 05568746e2ae12bbcf5396e4bb9a7a5493f524d9 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Wed, 31 Aug 2022 19:47:48 +0200 Subject: [PATCH] Dropdown: use Popover s new anchor prop (#43698) --- packages/components/src/dropdown/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/components/src/dropdown/index.js b/packages/components/src/dropdown/index.js index c260d27ffee7d..2ec44fb5d907b 100644 --- a/packages/components/src/dropdown/index.js +++ b/packages/components/src/dropdown/index.js @@ -83,7 +83,10 @@ export default function Dropdown( props ) { } const args = { isOpen, onToggle: toggle, onClose: close }; - const hasAnchorRef = + const hasPopoverAnchor = + !! popoverProps?.anchor || + // Note: `anchorRef`, `getAnchorRect` and `anchorRect` are deprecated and + // be removed from `Popover` from WordPress 6.3 !! popoverProps?.anchorRef || !! popoverProps?.getAnchorRect || !! popoverProps?.anchorRect; @@ -110,7 +113,9 @@ export default function Dropdown( props ) { // This value is used to ensure that the dropdowns // align with the editor header by default. offset={ 13 } - anchorRef={ ! hasAnchorRef ? containerRef : undefined } + anchor={ + ! hasPopoverAnchor ? containerRef.current : undefined + } { ...popoverProps } className={ classnames( 'components-dropdown__content',