@@ -63,6 +63,8 @@ function GridItemResizerInner( {
63
63
* This ref is necessary get the bounding client rect of the resizer,
64
64
* because it exists outside of the iframe, so its bounding client
65
65
* rect isn't the same as the block element's.
66
+ * It needs to be added to a dummy element because we can't be sure if
67
+ * the popover or the resizer are on the page when we need them.
66
68
*/
67
69
const resizerRef = useRef ( null ) ;
68
70
@@ -131,7 +133,6 @@ function GridItemResizerInner( {
131
133
clientId = { clientId }
132
134
__unstablePopoverSlot = "block-toolbar"
133
135
additionalStyles = { styles }
134
- __unstableContentRef = { resizerRef }
135
136
>
136
137
< ResizableBox
137
138
className = "block-editor-grid-item-resizer__box"
@@ -164,9 +165,8 @@ function GridItemResizerInner( {
164
165
* isn't directly above the handle, so we try to detect if it happens
165
166
* outside the grid and dispatch a mouseup event on the handle.
166
167
*/
167
- const rootElementParent =
168
- rootBlockElement . closest ( 'body' ) ;
169
- rootElementParent . addEventListener (
168
+ controller . abort ( ) ;
169
+ event . target . ownerDocument . addEventListener (
170
170
'mouseup' ,
171
171
( ) => {
172
172
event . target . dispatchEvent (
@@ -221,6 +221,10 @@ function GridItemResizerInner( {
221
221
controller . abort ( ) ;
222
222
} }
223
223
/>
224
+ < div
225
+ className = "block-editor-grid-item-resizer__dummy"
226
+ ref = { resizerRef }
227
+ > </ div >
224
228
</ BlockPopoverCover >
225
229
) ;
226
230
}
0 commit comments