feat(ui): let keyboard-driven lists drive ListRow

Merged
CH
8d ago
+108-3

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 a Ref object, 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.
  • onKeyDown fires 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'.
  • onContextMenu fires 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