Skip to content

ResolveTarget

@whittakertech/mosaic / resolveTarget

Function: resolveTarget()

function resolveTarget(
from,
activeNode,
root,
selectors,
instanceId): ResolvedTarget | null;

Defined in: drag/resolver.ts:150

Resolves the innermost valid drop destination at a position in the DOM.

Walks upward from from to the nearest element matching the node — or, when configured, drop-target — selector, scoped to root. Returns null when no valid destination exists, or when the only match is the active node itself (a node is never a drop destination for its own drag).

Parameters

from

The element under the pointer (e.g. from elementFromPoint)

Element | null

activeNode

HTMLElement

The node currently being dragged

root

HTMLElement

The Mosaic root bounding valid destinations

selectors

The active selector configuration

children?

string

Optional selector identifying child elements within a draggable node.

Remarks

This selector is intended for structural clarity and future extensibility. It is not required for basic drag-and-drop behavior.

dropTarget?

string

Optional selector identifying explicit drop destinations.

Remarks

When provided, elements matching this selector become valid drop targets in addition to draggable nodes, and are distinguished from nodes via the targetType field on hover events and the dropTarget CSS class.

When omitted, v0.2 behavior is preserved — draggable nodes are the only valid drop targets.

group?

string

Optional selector identifying logical grouping elements.

Remarks

When provided, group-container elements scope drag behavior: a node dragged within its group reorders only among siblings in that group, and drops outside the group are rejected (reason "group-boundary") unless MosaicOptions.crossGroupDrag is enabled.

handle?

string

Optional selector identifying a drag handle within a node.

Remarks

When provided, pointerdown only initiates a drag when its target matches (or is a descendant of) an element matching this selector within the node — the handle may be nested at any depth. A pointerdown elsewhere on the node is ignored.

When omitted, the entire node remains draggable (v0.2 behavior).

node

string

Selector matching draggable nodes.

This selector defines which elements participate in drag operations.

instanceId

string

The mosaicInstanceId of the Mosaic instance whose root/selectors are being probed (#158/RM-21.2) — stamped onto the returned ResolvedTarget verbatim. Callers resolving against their own instance pass their own id; callers probing a linked peer as a cross-instance fallback pass the peer’s id.

Returns

ResolvedTarget | null

A ResolvedTarget, or null when nothing valid is under the pointer