Skip to content

Core: ListChain::keys_from, a virtual list driven from a search field (#345) - #400

Merged
samitbasu merged 17 commits into
mainfrom
keys-345
Nov 19, 2026
Merged

samitbasu merged 17 commits into
mainfrom
keys-345

Conversation

@samitbasu

@samitbasu samitbasu commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Part of #345. The user chose the virtual list for the palette's results now, so core gains a list a search field drives. Built on #391 (C2–C4) and #397 (C1, and so #381), which are merged in; this diff shows their changes until they land.

API for review (ListChain, vlist)

  • ListChain::keys_from(field: Id) -> Self: a listbox whose keys come from the node field (from Builder::id_of) while the focus is in it.
    • The arrows and Page Up/Down move the highlight; Home and End stay the field's.
    • Enter activates the highlight.
    • A click on a row activates it and gives the focus back to the field.
    • The field announces that it controls the list, and the highlighted row as its active descendant.
    • The list is no Tab stop of its own.
    • It implies nav(ListNav::Listbox).
  • ListChain::highlight_first() -> Self: the first enabled row is highlighted when the list is first laid out and whenever its rows change, so Enter picks the first match at once.
  • ListChain::row_enablement(impl Fn(R) -> Enablement) -> Self: a disabled row is announced disabled, and the keys, the pointer and activation pass it by.
  • ListChain::row_mark(impl Fn(R) -> Option<Mark>) -> Self: a row's check, announced as toggled.
  • Builder::virtual_list(key, tw, rows: impl Into<Cow<'f, [R]>>) (was &'f [R]): rows can be computed in the frame (a filtered result list) as well as borrowed. Every existing caller compiles unchanged.
  • MenuStyle::box_classes(&TextSpec) -> Tw and MenuStyle::row_height(&TextSpec) -> f32 are now public, for a list drawn as a menu outside core (the extras palette).

Shape

  • A listbox highlight's owner is one enum (nav::Owner: an overlay with or without an anchor, or a list keyed by itself or from a field), replacing an anchor plus a list: bool.
  • The owner decides which focus keys the listbox and which node announces it, so Enter, the arrows and the announcements cannot disagree.
  • The field's controls relation goes through Core: NodeHandle::controls(Id), the aria-controls relation (part of #350) #381's relation path, gathered from the lists laid out in the pass.

Behaviour changes: none for existing lists. Every vlist test is unchanged.

Tests (tests/it/vlist_keys_from.rs, real path)

  • The first row is highlighted as the list opens.
  • The field's arrows move the highlight, and the field keeps the focus.
  • Enter activates the highlighted row.
  • Home and End stay the field's.
  • Page Down moves a page.
  • Typing narrows the rows and highlights the first again.
  • The field controls the list.
  • The arrows pass disabled rows by, and a disabled row says so.
  • A row with a mark announces it.
  • A click activates a row and leaves the focus in the field.
  • In a centred dialog, the first row is highlighted and Enter picks it.

Also nav unit tests for skipping disabled rows.

Checks

🤖 Generated with Claude Code

samitbasu and others added 10 commits November 18, 2026 13:42
# Conflicts:
#	src/builder.rs
#	src/draw.rs
…345)

C1 of the #345 design note. While a listbox overlay is open, the node it is
anchored to (the focused text edit of a field, or a select's trigger) now
says that it controls the listbox and which item the arrows reached, the
aria-controls and aria-activedescendant of the web; it already said
expanded and has_popup, and those now go to the same node. A virtual list's
active descendant goes the same way.

Shape: #381's relation path is generalised rather than copied. `Pass`
gathers `relation::Relation`s (`Controls`, `ActiveDescendant`) instead of
`(Id, Id)` pairs; the overlays' controls relations come back from
`overlay_input::judge`, the highlights' from `nav::relations`, and all are
announced once, after the pass has drawn and the keys have moved the
highlight, only between nodes both in the tree. The virtual list's
`set_active_descendant` from a row's draw closure (the unsafe shape #387
names) is gone. The listbox's node is its blocker's, now named by
`draw::blocker_id`.

Behaviour changes:
- The select's trigger announces `controls` (its listbox) and the active
  descendant (the highlighted option) while open.
- A listbox overlay anchored to a text field announces expanded,
  has_popup, controls and the active descendant on the field's text edit,
  which has the focus, instead of expanded and has_popup on the field's
  leaf node.

Builds on #381 (merged in, with its conflicts against main resolved by
keeping both sides).

Part of #345.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
The user chose the virtual list for the palette's results now (#345), so a
search field must drive a virtual list it does not focus. New on
`ListChain`:

- `keys_from(field: Id)`: a listbox whose keys come from the node `field`
  while the focus is in it. The arrows and Page keys move the highlight
  (Home and End stay the field's), Enter activates it, a click on a row
  gives the focus back to the field, and the field announces that it
  controls the list and which row is highlighted. The list is no Tab stop
  of its own.
- `highlight_first()`: the first enabled row is highlighted when the list
  is first laid out and whenever its rows change, so Enter picks the first
  match at once.
- `row_enablement(Fn(R) -> Enablement)`: a disabled row is announced
  disabled and the keys, the pointer and activation pass it by.
- `row_mark(Fn(R) -> Option<Mark>)`: a row's check, announced as toggled.

`Builder::virtual_list` now takes `impl Into<Cow<'f, [R]>>`, so the rows
can be computed in the frame (a filtered result list) as well as borrowed;
every existing caller still compiles. `MenuStyle::box_classes` and
`MenuStyle::row_height` are public, for a list drawn as a menu outside
core.

Shape: a listbox highlight's owner is now one enum (`nav::Owner`: an
overlay with or without an anchor, or a list keyed by itself or from a
field) instead of an anchor plus a `list` flag, and the same owner decides
which focus keys it and which node announces it. The field's controls
relation goes through #381's relation path.

Behaviour changes: none for existing lists (a list keyed by itself works
as before; all vlist tests unchanged).

Part of #345.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
samitbasu and others added 7 commits November 19, 2026 11:22
`controls` stays in the relation machinery of this branch; main's
accessibility parent and accessible description come with controls-350.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
Main's `when`/`when_some` impl met this branch's `ListChain<R: Clone>`.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
@samitbasu

Copy link
Copy Markdown
Owner Author

Approved by the user on its tests (2026-11-19). GitHub's required checks pass on the branch merged with current main. Merging.

@samitbasu
samitbasu merged commit f1753fa into main Nov 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant