Skip to content

Commit ad917d5

Browse files
stokesmannoisysockstalldantellthemachines
authored
Fix grid resizer drag over embed (#64098)
* Capture pointer to avoid flaky dragging * Remove manual mouseup dispatch Co-authored-by: noisysocks <noisysocks@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org> Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org>
1 parent 7b067aa commit ad917d5

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

packages/block-editor/src/components/grid/grid-item-resizer.js

+9-15
Original file line numberDiff line numberDiff line change
@@ -119,28 +119,22 @@ function GridItemResizerInner( {
119119
} }
120120
bounds={ bounds }
121121
boundsByDirection
122+
onPointerDown={ ( { target, pointerId } ) => {
123+
/*
124+
* Captures the pointer to avoid hiccups while dragging over objects
125+
* like iframes and ensures that the event to end the drag is
126+
* captured by the target (resize handle) whether or not it’s under
127+
* the pointer.
128+
*/
129+
target.setPointerCapture( pointerId );
130+
} }
122131
onResizeStart={ ( event, direction ) => {
123132
/*
124133
* The container justification and alignment need to be set
125134
* according to the direction the resizer is being dragged in,
126135
* so that it resizes in the right direction.
127136
*/
128137
setResizeDirection( direction );
129-
130-
/*
131-
* The mouseup event on the resize handle doesn't trigger if the mouse
132-
* isn't directly above the handle, so we try to detect if it happens
133-
* outside the grid and dispatch a mouseup event on the handle.
134-
*/
135-
blockElement.ownerDocument.addEventListener(
136-
'mouseup',
137-
() => {
138-
event.target.dispatchEvent(
139-
new Event( 'mouseup', { bubbles: true } )
140-
);
141-
},
142-
{ once: true }
143-
);
144138
} }
145139
onResizeStop={ ( event, direction, boxElement ) => {
146140
const columnGap = parseFloat(

0 commit comments

Comments
 (0)