Choose one path through a tree of options from a button whose popup shows one listbox per level, with Menu's submenu keys and hover, and form support.
Choose one path through a tree of options (a region, then a country, then a city) from a
button whose popup shows one list per level, side by side. It works in a native <form> as a
Select does: it submits, resets and validates.
The APG has no cascading pattern and Base UI has no CascadeSelect. The APG-closest shape is taken:
the APG select-only combobox
(a Select) whose popup holds one listbox per open level; the levels open
and close as the APG menu's submenus do (Right opens, Left closes, mirrored in RTL), with
Menu's hover delay and safe area. Zag's and Ark's cascade select and Ant
Design's Cascader were read for the behaviour, never copied.
The value is a path: the values from the first level down (["europe", "france", "paris"]),
[] when nothing is chosen.
The tree is items (required): { value, label, disabled?, children? }[], the toolkit's
CascadeItem. An item with children is a parent, else a leaf.
One Level per depth: render a Level for each depth of your tree; a Level hands its items
(the first level's, or the children of the item open at the depth above) to its content, which
renders an Item per entry. A Level whose depth is not open is hidden.
The levels and the highlight: the highlight moves within one level; moving it closes the
levels below. A keyboard highlight never opens a level by itself: Right (or Enter, Space) does,
as in the APG menu. Hovering a parent for 100 ms opens its level, the highlight staying on it.
Safe area: while the pointer moves from a parent whose level is open toward that level,
crossing sibling items does not highlight them nor close the level (Menu's).
Choosing: a leaf is chosen by Enter, Space, Tab or a click, and the popup closes. A parent
opens its level and is not chosen; with changeOnSelect, Enter, Space and a click also
choose the path up to it and the popup stays open on it, so the user can go on. A disabled item
can be highlighted but is never chosen, and a disabled parent never opens its level.
Focus: DOM focus always stays on the Trigger; the highlighted item is announced with
aria-activedescendant.
A parent option says it opened a level with aria-controls (an option may not carry
aria-expanded nor aria-haspopup), and the deeper Level is named by its parent
(aria-labelledby). Style it from data-has-children and data-expanded.
Forms: a hidden input carries name and the path joined by valueSeparator (/ by
default: location=europe/france/paris); required blocks a submission with no path; a form
reset returns an uncontrolled CascadeSelect to defaultValue. In a Field,
the Trigger is the field's labelable control.
Value shows the last chosen item's label, or, with separator, the labels of the whole path
joined by it ("Europe / France / Paris" with " / "). The labels and the separator are the
app's text. On the server, the Value shows a defaultValue's labels, read from items.
Every part also takes what the primitive contract gives:
render (Vue: as and the render slot), a class and a style, a ref, and any attribute, which
it forwards. The names below are React's; Vue binds them the same way (v-model:value,
v-model:open), and Angular as inputs and outputs ([(value)], (valueChangeDetails)).
role="combobox", type="button", aria-haspopup="listbox", aria-expanded, aria-controls (the open Levels, while open), aria-activedescendant (the highlighted item, while open), aria-required, disabled, data-popup-open, data-placeholder, data-disabled; in a Field, the field's states
role="listbox", data-depth; the first level aria-labelledby the Trigger's labels, a deeper one its parent option; hidden while not open
Item
role="option", aria-selected (on the chosen path at its depth), aria-disabled, data-highlighted, data-selected, data-disabled, data-has-children (a parent), data-expanded and aria-controls (its children's Level) while its level is open
ItemIndicator
aria-hidden="true"
hidden input
name, value (the path joined by valueSeparator), required, disabled, aria-hidden="true", tabindex="-1"