DropIndicator
Where the drag under way would drop - a line before or after a row, or the row's box - from the drag and drop feature's entry.
DropIndicator shows the target of a drag: a Tree.Root whose model has the drag and drop
feature (dragAndDrop()) or the foreign drop feature (foreignDrop()). It comes with them, from
@fragiola/tree-react/drag-and-drop (and /foreign-drop; @fragiola/tree-vue/…,
@fragiola/tree-angular/… with TreeDropIndicatorDirective): a tree that never imports them does
not ship it. It renders only while a drag has a drop target, absolutely positioned in the root: for
before and after, a zero-height line at the target's level (starting
(level - 1) * indentation + indicatorInset pixels from the root's inline start); for inside,
the row's box. It sets only its geometry, from engine.get("drop-indicator"); draw the line or the
box yourself. It is hidden from assistive technology: the live region announces the drag. Without
a drag feature, it renders nothing.
import { createTreeModel, Tree } from "@fragiola/tree-react";
import { DropIndicator, dragAndDrop } from "@fragiola/tree-react/drag-and-drop";
const features = [dragAndDrop()] as const;
const model = createTreeModel<Types, typeof features>(json, { features });
<Tree.Root model={model} aria-label="Files">
<Tree.Items<Types>>{(item) => <FileItem item={item} />}</Tree.Items>
<DropIndicator className="drop-indicator" />
</Tree.Root>.drop-indicator[data-drop-position="before"],
.drop-indicator[data-drop-position="after"] {
border-top: 2px solid #2563eb;
margin-top: -1px;
}
.drop-indicator[data-drop-position="inside"] {
border: 2px solid #2563eb;
}Rows whose label starts after a toggle, a grip or padding start the line there with the
indicatorInset option (px) of dragAndDrop() (or foreignDrop()), as the examples do
(Keeping drops in line).
Props
DropIndicatorProps has no props of its own: it takes the
common primitive props (on a div), with DropIndicatorState.
State
DropIndicatorState:
| field | type | description |
|---|---|---|
position | DropPosition: "before" | "after" | "inside" | where the drop goes, relative to itemId |
itemId | string | null | the item the position is relative to (null: an empty tree) |
level | number | the level the dropped items take (1 for the root) |
Attributes
| attribute | when |
|---|---|
aria-hidden | always |
data-tree-part="drop-indicator" | always |
data-drop-position | before, after or inside |
data-depth | the level the dropped items take, minus one |
Structural style: position: absolute, inset-inline-start, inset-inline-end: 0,
inset-block-start, block-size and pointer-events: none.
Tree.Toggle
Expands or collapses the enclosing item on a press. A pointer affordance hidden from assistive technology, since the item carries aria-expanded.
Tree.LiveRegion
The tree's polite live region. It shows the text your announce function returns for each drag step or failed load, and writes none of its own.