Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix grid item resizing in non-iframed editor. #61636

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}

Loading