Skip to content

Commit

Permalink
Try popover ref
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed May 9, 2024
1 parent 7e4dbb8 commit 19e8ae2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function GridItemResizer( { clientId, onChange } ) {
* necessary because the resizer exists outside of the iframe, so
* its bounding client rect isn't the same as the block element's.
*/
const resizerDummyRef = useRef( null );
const resizerRef = useRef( null );

if ( ! blockElement ) {
return null;
Expand Down Expand Up @@ -62,8 +62,7 @@ export function GridItemResizer( { clientId, onChange } ) {
offsetWidth: rootBlockElement.offsetWidth,
offsetHeight: rootBlockElement.offsetHeight,
getBoundingClientRect: () => {
const resizerTop =
resizerDummyRef.current?.getBoundingClientRect()?.top;
const resizerTop = resizerRef.current?.getBoundingClientRect()?.top;
// Fallback value of 60 to account for editor top bar height.
const heightDifference = resizerTop
? resizerTop - blockClientRect.top
Expand Down Expand Up @@ -96,6 +95,7 @@ export function GridItemResizer( { clientId, onChange } ) {
clientId={ clientId }
__unstablePopoverSlot="block-toolbar"
additionalStyles={ styles }
__unstableContentRef={ resizerRef }
>
<ResizableBox
className="block-editor-grid-item-resizer__box"
Expand Down Expand Up @@ -183,10 +183,6 @@ export function GridItemResizer( { clientId, onChange } ) {
} );
} }
/>
<div
className="block-editor-grid-item-resizer__dummy"
ref={ resizerDummyRef }
></div>
</BlockPopoverCover>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,3 @@
}
}

.block-editor-grid-item-resizer__dummy {
position: absolute;
width: 100%;
height: 100%;
z-index: -1;
}

0 comments on commit 19e8ae2

Please sign in to comment.