API: primitives (@fragiola/tree-react, @fragiola/tree-vue, @fragiola/tree-angular)
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.
Tree.LiveRegion is a role="status", aria-live="polite" element showing the latest text the
root's announce returned. The package writes no text: without announce, it stays empty. The
WAI-ARIA APG asks a drag and drop to be perceivable without sight; this is where your words go.
Hide it visually with your own class.
<Tree.Root<Types> defaultTree={json} announce={announce} aria-label="Files">
<Tree.Items<Types>>{(item) => <FileItem item={item} />}</Tree.Items>
<Tree.LiveRegion className="visually-hidden" />
</Tree.Root>announce receives an AnnounceEvent and returns a string, or undefined to say nothing:
| event | fields | when |
|---|---|---|
drag-start | itemIds, keyboard, target (DropTarget | null) | a drag starts (pointer, or keyboard when keyboard is true); a keyboard drag's target is where it starts, announced with the start in one message (no drag-over follows it in the same tick); null for a pointer drag |
drag-over | itemIds, target (DropTarget | null) | the drop target changes; null when there is no valid one |
drop | itemIds, target | the items were dropped (one item.move) |
drag-cancel | itemIds | the drag was cancelled |
load-error | itemId, error | a load of an item's children failed |
The latest text is also engine.get("announcement"). See
Drag and drop.
Props
LiveRegionProps has no props of its own: it takes the
common primitive props (on a div), with LiveRegionState.
State
LiveRegionState:
| field | type | description |
|---|---|---|
announcement | string | the latest text announce returned ("" before any) |
Attributes
| attribute | when |
|---|---|
role="status" | always |
aria-live="polite" | always |
aria-atomic | always |
data-tree-part="live-region" | always |