Skip to content

Drags continue even if the layout shifts on drag start - #61527

Merged
chromium-wpt-export-bot merged 1 commit into
masterfrom
chromium-export-cl-7748202
Jul 27, 2026
Merged

Drags continue even if the layout shifts on drag start#61527
chromium-wpt-export-bot merged 1 commit into
masterfrom
chromium-export-cl-7748202

Conversation

@chromium-wpt-export-bot

@chromium-wpt-export-bot chromium-wpt-export-bot commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

This CL fixes a bug with drag and drop where a drag will not happen if
the dragstart listener removes the drag source or generates a layout
shift.

When a drag starts, blink will try hit-testing the drag start location
after the dragstart event is fired to determine the dragged element
and create an overlay image for it. If listeners of the dragstart
event caused a layout shift or removed the element from the document,
then the hit test will fail and the drag operation will be aborted.

This CL reorders the steps in the sequence to create a drag by moving
the hit testing and image overlay generation to before the dragstart
event is fired in PopulateDragDataTransfer. With this change, even if
dragstart removes an element from the document, the user will still
be presented with the correct drag overlay image.

In addition to the new tests in this CL, these changes were manually
verified in the WPT remove/ and overlay/ drag and drop directories to
confirm correct UA behavior.

Bug: 434130455
Change-Id: I84bab2edb505b113e8a9481109f196d225d77718
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7748202
Reviewed-by: Mustaq Ahmed <mustaq@chromium.org>
Commit-Queue: Gaston Rodriguez <gastonr@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1668792}

This CL fixes a bug with drag and drop where a drag will not happen if
the `dragstart` listener removes the drag source or generates a layout
shift.

When a drag starts, blink will try hit-testing the drag start location
*after* the `dragstart` event is fired to determine the dragged element
and create an overlay image for it. If listeners of the `dragstart`
event caused a layout shift or removed the element from the document,
then the hit test will fail and the drag operation will be aborted.

This CL reorders the steps in the sequence to create a drag by moving
the hit testing and image overlay generation to *before* the `dragstart`
event is fired in `PopulateDragDataTransfer`. With this change, even if
`dragstart` removes an element from the document, the user will still
be presented with the correct drag overlay image.

In addition to the new tests in this CL, these changes were manually
verified in the WPT remove/ and overlay/ drag and drop directories to
confirm correct UA behavior.

Bug: 434130455
Change-Id: I84bab2edb505b113e8a9481109f196d225d77718
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7748202
Reviewed-by: Mustaq Ahmed <mustaq@chromium.org>
Commit-Queue: Gaston Rodriguez <gastonr@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1668792}

@wpt-pr-bot wpt-pr-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The review process for this patch is being conducted in the Chromium project.

@chromium-wpt-export-bot
chromium-wpt-export-bot merged commit 8e57318 into master Jul 27, 2026
28 checks passed
@chromium-wpt-export-bot
chromium-wpt-export-bot deleted the chromium-export-cl-7748202 branch July 27, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants