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 areTakeBecause
one row or column, no typing to findRovingTabindexthe smallest: one tab stop, arrows, Home and End
one row or column, and typing finds oneListNavigationcombines RovingTabindex and Typeahead under one keydown owner
cells in rows of a fixed columnsGridNavigationup and down mean the same column
nested, some of them openTreeNavigationLeft and Right open, close and step out; openness is in the Model
placed anywhere, with no rows or columnsSpatialNavigationthe 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.

TakeIt acts whenAnd moves focus to
FocusScopean overlay mounts and unmountsin: its first tabbable; contained while open; out: back to the opener
FocusReturnan 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
FocusRecoverythe focused part is removed, hidden, made inert or movedthe part's declared steps (next, previous, parent, { part }, owner)
FollowTabStopa transition moves or removes the roving stop's rowthe 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).