Skip to content

Commit

Permalink
Iframe: Fix positioning when dragging over an iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewserong committed Oct 9, 2023
1 parent 6bd8578 commit 0df3246
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/block-editor/src/components/iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ function bubbleEvent( event, Constructor, frame ) {
init[ key ] = event[ key ];
}

if ( event instanceof frame.ownerDocument.defaultView.MouseEvent ) {
// Check if the event is a MouseEvent generated within the iframe.
// If so, adjust the coordinates to be relative to the position of
// the iframe. This ensures that components such as Draggable
// receive coordinates relative to the window, instead of relative
// to the iframe. Without this, the Draggable event handler would
// result in components "jumping" position as soon as the user
// drags over the iframe.
if ( event instanceof frame.contentDocument.defaultView.MouseEvent ) {
const rect = frame.getBoundingClientRect();
init.clientX += rect.left;
init.clientY += rect.top;
Expand Down

0 comments on commit 0df3246

Please sign in to comment.