Active focus, expansion and selection¶
Active focus is one visible eligible item referenced by the root. A collapsed
ancestor always makes descendants unavailable. Hidden, inert, aria-hidden,
aria-disabled, disabled, invisible or non-rendered items are unavailable.
Refresh never prunes selected items. Constructor selected may initialize
unavailable/collapsed entries; later replacements can carry or remove already
selected unavailable entries but cannot newly add them. This permits hidden-tab
models and retained selections across collapse.
Collapse hides active descendants and quietly falls active focus back to the nearest eligible visible ancestor, then the nearest eligible preorder position. Selection is independent and retained. All-unavailable retires root Tab/reference and sets active=-1. Recovery is quiet. A pointer toggle makes that branch active; it does not select it.
| Input while root focused | Behavior |
|---|---|
| Up/Down, Home/End | Traverse visible eligible preorder. Single mode selects a changed destination; multiple mode changes only active focus. |
| Ctrl/Meta + Up/Down/Home/End | Change active focus without single-mode selection. |
| Right | Expand a collapsed branch without selection; otherwise move to its first eligible direct child. |
| Left | Collapse an expanded branch without selection; otherwise move to its nearest eligible ancestor. |
| Space | Select active in single mode, toggle active selection in multiple mode. |
| Ordinary row click | Replace selection with the eligible row and restore root focus. |
| Ctrl/Meta row click, multiple mode | Toggle the eligible row without removing retained unavailable selections. |
| Shift + Up/Down/Home/End or row click, multiple mode | Add eligible visible range to a captured baseline; shrinking removes only the range additions. |
| Native branch toggle activation | Expand/collapse only; restore root focus. |
No-movement directional boundaries do not select an unrelated active model. Expansion changes, Left/Right, eligibility changes, explicit model replacement, Space (including Shift+Space), Shift release, window blur or document hiding clear the range anchor. A range cannot newly add unavailable/collapsed entries. Composing, Alt, Ctrl/Meta+Space/Left/Right, Enter and unrelated keys stay consumer owned. Tab remains native. Consumers own other modifier behavior.
Toggle eligibility matters separately: hidden/disabled/unavailable native toggles cannot admit pointer or keyboard expansion. Programmatic model updates are separate and may expand such a branch. Native pointerdown/default button focus remains intact: a button may receive focus before click. The tree takes its transition guard, requests root focus and verifies actual original-document activeElement plus current row/toggle eligibility before model changes. Rejected/redirected/throwing focus, focus-time disable/hide, retirement or disposal admits no expansion/selection callback. Accepted activation returns root virtual focus. A nested toggle label emits only one expansion notification.