feat(ui): let keyboard-driven lists drive ListRow
Merged
CH
8d ago+108+108+012345678901234567890123456789-3-3-0123456789
What
D37 (#3414 stack) found that ListRow (F36) couldn't drive a keyboard-driven list. This adds three props, with no change to how the row looks:
ref?: RefCallback<HTMLElement>receives the element that takes the row's focus. That's the row's press<button>, or the<li>when the row opens nothing. A callback rather than aRefobject, so a list can keep each row's element by its own key, and so the one prop fits both element types without a cast.onKeyDownfires on the row's press alone (j/k, arrows, Enter, Backspace). A row that opens nothing takes no focus and hears no keys, which would only be its acts'.onContextMenufires on the whole row, including its acts, so the app can open its own menu there.
Visible changes
None. No catalog example changes: these are behaviour callbacks with nothing new to see.
Tests
jsdom, through the public API:
- Focus can be returned to a row's press through its ref.
- A row that opens nothing hands its
<li>to the ref. - A key pressed on the row reaches
onKeyDown, and a key on an inert row's act does not. - A right-click on the row or on its act reaches
onContextMenu.
Not verified
Not verified on a Mac (nothing Mac-specific changes).
š¤ Generated with Claude Code