Primitives / Interaction
Choosing between near neighbours
Four pairs look alike. Each answer is the one fact that differs.
Arrow keys over items. Pick by how the items are laid out.
| The items are | Take | Because |
|---|---|---|
| one row or column, no typing to find | RovingTabindex | the smallest: one tab stop, arrows, Home and End |
| one row or column, and typing finds one | ListNavigation | combines RovingTabindex and Typeahead under one keydown owner |
cells in rows of a fixed columns | GridNavigation | up and down mean the same column |
| nested, some of them open | TreeNavigation | Left and Right open, close and step out; openness is in the Model |
| placed anywhere, with no rows or columns | SpatialNavigation | the nearest item drawn that way, measured when the key is pressed |
Typeahead alone is for a host whose focus is managed elsewhere.
Keeping focus. The four differ by what makes focus move.
| Take | It acts when | And moves focus to |
|---|---|---|
FocusScope | an overlay mounts and unmounts | in: its first tabbable; contained while open; out: back to the opener |
FocusReturn | an overlay whose own restoring is not ours unmounts with focus lost (a native <dialog>) | the opener, else by FocusRecovery's steps, else the layer below |
FocusRecovery | the focused part is removed, hidden, made inert or moved | the part's declared steps (next, previous, parent, { part }, owner) |
FollowTabStop | a transition moves or removes the roving stop's row | the container's stop (the roving primitives and TreeNavigation attach it themselves) |
FocusScope and FocusReturn are about an overlay; FocusRecovery and
FollowTabStop are about a list that changes under the focus. A custom overlay
takes FocusScope; add FocusReturn when something else restores focus.
Editing text. InlineEdit edits a plain value in an <input> and keeps the
draft in the Model; the parent saves or refuses the Committed value.
EditableText reads the text typed into a contenteditable field the view
already draws (a label on a canvas, a node's title), one or several lines, and
reports it as it changes.
Moving things. Move reports a pointer drag's deltas for one element (a
window, a handle). PointerDrag drags one marked descendant onto another
(a place in a list). Marquee moves nothing: it reports the marked items a lasso
from empty space covers. Reorder is the keyboard's path
and the pointer's, as one draft (Moved { id, to }) for a list or tree, and
uses PointerDrag itself. For a window or card, a key and a drag share
Move.nudge and Box (in state).