diff --git a/packages/block-editor/src/components/block-popover/index.js b/packages/block-editor/src/components/block-popover/index.js index ae493fb9cf5b5e..5b8a2231bb83ee 100644 --- a/packages/block-editor/src/components/block-popover/index.js +++ b/packages/block-editor/src/components/block-popover/index.js @@ -73,7 +73,6 @@ export default function BlockPopover( { __unstableBoundaryParent // Observe movement for block animations (especially horizontal). __unstableObserveElement={ selectedElement } - shouldAnchorIncludePadding // Used to safeguard sticky position behavior against cases where it would permanently // obscure specific sections of a block. __unstableEditorCanvasWrapper={ __unstableContentRef?.current } diff --git a/packages/components/src/popover/index.js b/packages/components/src/popover/index.js index 5b97ab144c9894..042d3a4a20bfa3 100644 --- a/packages/components/src/popover/index.js +++ b/packages/components/src/popover/index.js @@ -47,7 +47,6 @@ function computeAnchorRect( anchorRect, getAnchorRect, anchorRef = false, - shouldAnchorIncludePadding, container ) { if ( anchorRect ) { @@ -98,17 +97,14 @@ function computeAnchorRect( container ); - if ( shouldAnchorIncludePadding ) { - return rect; - } - - return withoutPadding( rect, anchorRef ); + return rect; } const { top, bottom } = anchorRef; const topRect = top.getBoundingClientRect(); const bottomRect = bottom.getBoundingClientRect(); - const rect = offsetIframe( + + return offsetIframe( new window.DOMRect( topRect.left, topRect.top, @@ -118,12 +114,6 @@ function computeAnchorRect( top.ownerDocument, container ); - - if ( shouldAnchorIncludePadding ) { - return rect; - } - - return withoutPadding( rect, anchorRef ); } if ( ! anchorRefFallback.current ) { @@ -131,45 +121,12 @@ function computeAnchorRect( } const { parentNode } = anchorRefFallback.current; - const rect = offsetIframe( + + return offsetIframe( parentNode.getBoundingClientRect(), parentNode.ownerDocument, container ); - - if ( shouldAnchorIncludePadding ) { - return rect; - } - - return withoutPadding( rect, parentNode ); -} - -function getComputedStyle( node ) { - return node.ownerDocument.defaultView.getComputedStyle( node ); -} - -function withoutPadding( rect, element ) { - const { - paddingTop, - paddingBottom, - paddingLeft, - paddingRight, - } = getComputedStyle( element ); - const top = paddingTop ? parseInt( paddingTop, 10 ) : 0; - const bottom = paddingBottom ? parseInt( paddingBottom, 10 ) : 0; - const left = paddingLeft ? parseInt( paddingLeft, 10 ) : 0; - const right = paddingRight ? parseInt( paddingRight, 10 ) : 0; - - return { - x: rect.left + left, - y: rect.top + top, - width: rect.width - left - right, - height: rect.height - top - bottom, - left: rect.left + left, - right: rect.right - right, - top: rect.top + top, - bottom: rect.bottom - bottom, - }; } /** @@ -252,7 +209,6 @@ const Popover = ( range, focusOnMount = 'firstElement', anchorRef, - shouldAnchorIncludePadding, anchorRect, getAnchorRect, expandOnMobile, @@ -304,7 +260,6 @@ const Popover = ( anchorRect, getAnchorRect, anchorRef, - shouldAnchorIncludePadding, containerRef.current ); @@ -480,7 +435,6 @@ const Popover = ( anchorRect, getAnchorRect, anchorRef, - shouldAnchorIncludePadding, position, contentSize, __unstableStickyBoundaryElement, diff --git a/packages/nux/src/components/dot-tip/index.js b/packages/nux/src/components/dot-tip/index.js index 7f1461ab585664..c604c456254280 100644 --- a/packages/nux/src/components/dot-tip/index.js +++ b/packages/nux/src/components/dot-tip/index.js @@ -50,7 +50,6 @@ export function DotTip( { position={ position } noArrow focusOnMount="container" - shouldAnchorIncludePadding role="dialog" aria-label={ __( 'Editor tips' ) } onClick={ onClick } diff --git a/packages/nux/src/components/dot-tip/test/__snapshots__/index.js.snap b/packages/nux/src/components/dot-tip/test/__snapshots__/index.js.snap index b72099d193cfa8..a737545c530122 100644 --- a/packages/nux/src/components/dot-tip/test/__snapshots__/index.js.snap +++ b/packages/nux/src/components/dot-tip/test/__snapshots__/index.js.snap @@ -10,7 +10,6 @@ exports[`DotTip should render correctly 1`] = ` onFocusOutside={[Function]} position="middle right" role="dialog" - shouldAnchorIncludePadding={true} >

It looks like you’re writing a letter. Would you like help?