Skip to content

Commit

Permalink
Fix grid item resizing in non-iframed editor. (#61636)
Browse files Browse the repository at this point in the history
Co-authored-by: tellthemachines <[email protected]>
Co-authored-by: andrewserong <[email protected]>
Co-authored-by: noisysocks <[email protected]>
  • Loading branch information
4 people authored May 14, 2024
1 parent 32bcc86 commit b941a1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ function GridItemResizerInner( {
* This ref is necessary get the bounding client rect of the resizer,
* because it exists outside of the iframe, so its bounding client
* rect isn't the same as the block element's.
* It needs to be added to a dummy element because we can't be sure if
* the popover or the resizer are on the page when we need them.
*/
const resizerRef = useRef( null );

Expand Down Expand Up @@ -131,7 +133,6 @@ function GridItemResizerInner( {
clientId={ clientId }
__unstablePopoverSlot="block-toolbar"
additionalStyles={ styles }
__unstableContentRef={ resizerRef }
>
<ResizableBox
className="block-editor-grid-item-resizer__box"
Expand Down Expand Up @@ -164,9 +165,8 @@ function GridItemResizerInner( {
* isn't directly above the handle, so we try to detect if it happens
* outside the grid and dispatch a mouseup event on the handle.
*/
const rootElementParent =
rootBlockElement.closest( 'body' );
rootElementParent.addEventListener(
controller.abort();
event.target.ownerDocument.addEventListener(
'mouseup',
() => {
event.target.dispatchEvent(
Expand Down Expand Up @@ -221,6 +221,10 @@ function GridItemResizerInner( {
controller.abort();
} }
/>
<div
className="block-editor-grid-item-resizer__dummy"
ref={ resizerRef }
></div>
</BlockPopoverCover>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@
}
}

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

0 comments on commit b941a1e

Please sign in to comment.