input: allow drag drop-point biasing within target bounding box#2159
Open
innocentnortey wants to merge 1 commit into
Open
input: allow drag drop-point biasing within target bounding box#2159innocentnortey wants to merge 1 commit into
innocentnortey wants to merge 1 commit into
Conversation
Extend the `drag` tool with optional `to_offset_x` / `to_offset_y` / `to_fraction_x` / `to_fraction_y` so callers can bias the drop point inside the target element's bounding rectangle instead of always dropping at the geometric center. When none of the new parameters are provided, the tool keeps the existing centroid-to-centroid behaviour (`fromHandle.drag(toHandle)` + 50 ms pause + `toHandle.drop(fromHandle)`) so every current caller is unaffected. When any of the new parameters are provided, the tool computes a custom point inside the target's bounding box and replicates the existing HTML5-drag emulation path (hover source → mouse.down → mouse.move to custom point → 150 ms pause → mouse.up). This avoids needing `setDragInterception(true)`, which would conflict with the default code path used by every other call site. Motivation: some drag-and-drop UIs expose a single visible drop zone whose geometric centre is not the safest or correct drop hotspot (e.g. Zoho Analytics Pivot View construction, where dropping a measure onto the visible Data shelf container can land in a neighbouring Rows shelf because the shelf centre overlaps it). In those layouts, dropping onto a child element deeper inside the intended shelf works reliably, which points at target-point geometry rather than source selection or timing as the failure mode. Adds a regression test that verifies the offset path lands in the expected sub-region of the target. Regenerated tool reference docs, CLI options, and tool-call metrics via `npm run gen`.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Ok
Em dom., 31 de mai. de 2026 às 02:27, google-cla[bot] <
***@***.***> escreveu:
… *google-cla[bot]* left a comment (ChromeDevTools/chrome-devtools-mcp#2159)
<#2159 (comment)>
Thanks for your pull request! It looks like this may be your first
contribution to a Google open source project. Before we can look at your
pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation
<https://github.com/ChromeDevTools/chrome-devtools-mcp/pull/2159/checks?check_run_id=78702423392>
of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of
the pull request.
—
Reply to this email directly, view it on GitHub
<#2159?email_source=notifications&email_token=CDNASINUV5YXXTTQI7KZ5O345O7C7A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINJYGU4DANZZGEY2M4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#issuecomment-4585807911>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/CDNASINVBMEEQ7I4PYLFFIT45O7C7AVCNFSM6AAAAACZUFHUZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DKOBVHAYDOOJRGE>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/CDNASIP2NV25LBWAFMRB3R345O7C7A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINJYGU4DANZZGEY2M4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSVGM33PORSXEX3JN5ZQ>
and Android
<https://github.com/notifications/mobile/android/CDNASIKOUWZTEQJGOVUMQLD45O7C7A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINJYGU4DANZZGEY2M4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSXGM33PORSXEX3BNZSHE33JMQ>.
Download it today!
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extend the existing
dragtool with four optional, backwards-compatible parameters that let callers bias the drop point inside the target element's bounding rectangle instead of always landing at the geometric centre:to_offset_x— CSS-pixel offset from target bounding-box top-leftto_offset_y— same, verticalto_fraction_x— fractional x position in[0, 1]to_fraction_y— fractional y position in[0, 1]When omitted,
drag(from_uid, to_uid)behaves exactly as it does today.Motivation
Some drag-and-drop UIs expose a single visible drop-zone element whose geometric centre is not the safest or correct drop hotspot.
A concrete repro is Zoho Analytics Pivot View construction. The Pivot editor has three drop shelves stacked vertically (Columns / Rows / Data). Dropping a measure onto the visible Data shelf container can land in the neighbouring Rows shelf when the shelf's bounding-box centre sits close to the Rows region. Dropping onto a child element located deeper inside the intended Data shelf — e.g., an existing chip body or its remove-button — works reliably, which points at target-point geometry rather than source selection or timing as the failure mode.
Today
chrome-devtools-mcp'sdragtool uses Puppeteer's defaultElementHandle.drag(toHandle)/toHandle.drop(fromHandle)path, which computes the drop point as the element's bounding-rect centroid viaclickablePoint(). That makes deceptive or overlapping drop-zone layouts hard to automate reliably.What changed
New optional drag parameters
Mutually exclusive per axis (offset OR fraction, not both).
Examples:
Backwards compatibility
If none of the new parameters are provided, the tool keeps the existing implementation verbatim:
fromHandle.drag(toHandle)toHandle.drop(fromHandle)This preserves behaviour for every existing caller.
Custom-target code path
If any of the new parameters is present, the tool:
dragoverhandlers, releases the mouse.This mirrors Puppeteer's existing HTML5-drag emulation path (the non-intercepted branch of
ElementHandle.drag) but lets the caller specify the target point. It intentionally avoidssetDragInterception(true)— enabling drag interception would makeElementHandle.drag(toHandle)(used by the default path) hang waiting forInput.dragIntercepted, breaking every existing call site.The 150 ms delay is intentional for HTML5 dragover-based UIs that need processing time between move and release.
Tests
Added a regression test in
tests/tools/input.test.tsthat verifiesdragwithto_offset_y: 10lands in the top region of a 120×120 drop target (i.e. the bias actually takes effect).Existing drag test continues to pass unchanged.
Generated artefacts
Regenerated via
npm run gen:docs/tool-reference.md— new params documentedsrc/bin/chrome-devtools-cli-options.ts— new CLI options entriessrc/telemetry/tool_call_metrics.json— new arg-type metrics entriesVerification
References
chrome-devtools-mcpcurrent drag implementation:src/tools/input.tsElementHandle.dragnon-intercepted branch:node_modules/puppeteer-core/lib/puppeteer/api/ElementHandle.js