feat(dnd): pluggable drop position resolver#1382
Merged
Merged
Conversation
Add an optional `PositionResolver` to the drop-target options that overrides how a pointer location within a target maps to a drop `Position` (or `null` for no drop), replacing the built-in cursor-quadrant threshold bands. Both DnD backends (`Droptarget` and `PointerDropTarget`) consult the same resolver at the drag-over resolve step; when unset the default quadrant logic runs unchanged — the drop loop is byte-for-byte identical for every existing consumer. This is a free-core extensibility hook: it lets a consumer drive drop resolution from a custom hit-test (e.g. aim-at-a-cell affordances) without re-implementing the overlay or commit path. Exposes `PositionResolver` + its arg/result types. Unit tests cover both backends: the resolver overriding the quadrant, a `null` result showing no drop target, and the default-when-absent path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…rop targets Expose the drop-position-resolver seam as a public app option, `DockviewOptions.dropPositionResolver`, and thread it (read live, like `getOverrideTarget`) into the 5-way group/layout drop targets — the group content (`content.ts`) and the whole-layout edges (`rootDropTargetService.ts`). Tab / header reorder targets are intentionally left on the default quadrant. Unset ⇒ the built-in cursor-quadrant behaviour, unchanged. With it set, an app can drive group-dock resolution from a custom hit-test (e.g. an aim-at-a-cell affordance) without re-implementing the overlay or commit path. Adds an integration test that the option reaches the content drop target, plus the PROPERTY_KEYS entry so `updateOptions` forwards it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
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.



A small, free-core extensibility seam for drag-and-drop: let a consumer override how a pointer location within a drop target maps to a drop
Position, replacing the built-in cursor-quadrant threshold bands — without re-implementing the overlay or commit path.What's added
PositionResolvercontract (dnd/droptarget.ts, exported):resolve({ x, y, width, height, zones, event }) => { position, edge? } | null.nullmeans "no drop here".DroptargetandPointerDropTarget) consult an optional, lazygetPositionResolvergetter at the drag-over resolve step — matching the existinggetOverrideTarget/getOverlayOutlinegetters, so the source can change at runtime. When unset, the default quadrant logic runs unchanged.DockviewOptions.dropPositionResolver, read live (swappable viaupdateOptions), threaded into the 5-way group/layout drop targets — group content + whole-layout edges. Tab/header reorder targets intentionally keep the default quadrant.Why
This is a reusable building block for aim-at-a-cell drop affordances and other custom drop-resolution UIs: the consumer supplies a hit-test, the existing overlay + commit path render/commit whatever
Positionit returns. Shipping it as a standalone seam lets it bake before anything builds on it (same approach astransformFloatingGroupDrag).Backward compatibility
Fully additive. With
dropPositionResolverunset (the default for everyone), the drop loop is byte-for-byte unchanged — no behaviour change for existing consumers.Tests
nullresult shows no drop target, and the default-when-absent path is unchanged.dropPositionResolveroption reaches the group content drop target.🤖 Generated with Claude Code