Keyboard and long lists
Shortcuts, keyboard navigation for lists and tables, and virtualization that keeps both working with thousands of rows.
Shortcuts
useShortcut(keys, handler, options) registers a key while the component is mounted, in UI SDK's shared shortcuts. Keys are +-joined (mod+k is ⌘K on Apple platforms and Ctrl+K elsewhere); a space makes a two-step sequence (g i). Plain keys never fire while someone types in an input, textarea or contenteditable, nor during IME composition. A modal pauses the page's shortcuts.
ShortcutScope name label activelimits the shortcuts registered inside it: to a region while focus is in it (active="focus", the default), or to an open panel (active). Inside a dialog they belong to that dialog.Button shortcut="u"andDropdownMenuItem shortcutbind the key in the current scope, show it withKbdand setaria-keyshortcuts.ShortcutHint keysdraws keys anywhere else.ShortcutsDialogopens on?and lists every shortcut with adescriptionthat can run where the person is, grouped by scope.- Shortcuts are an accelerator for people. Agents gain nothing new: they already press the same buttons and menu items by name (see Agents).
Keyboard map for lists and tables
List (link or button rows), the AgentTaskBoard backlog and table, and DataTable give their rows one tab stop with UI SDK's roving focus. A selectable List is a UI SDK Listbox, which moves with its own arrows; j, k and the page keys map onto them.
| Key | Does |
|---|---|
↓ or j | Next row |
↑ or k | Previous row |
Home / End | First and last row, rendered or not |
PageDown / PageUp | A screen of rows down or up |
Enter | Opens the row: its link or button, or the table's onRowOpen |
Space or x | Toggles the row's selection, where the list or table has one |
Tab | Leaves the rows; coming back lands on the row focused last |
The row that keys move to scrolls into view with the least scrolling. Keys typed in a control inside a row (a rename field, a menu) stay with that control. The rows keep the semantics of the list or table they belong to: no grid role is added.
Table cells
With navigation="cells", a DataTable moves by cell, as a spreadsheet does, on UI SDK's grid focus: the table takes the grid role and its cells one tab stop. A move renders only the cell left and the cell reached, and a row a virtualized table hasn't rendered is scrolled in first.
| Key | Does |
|---|---|
← / → | Previous and next cell in the row, following the text direction |
↑ / ↓ | The same column in the row above or below |
Home / End | First and last cell of the row |
Ctrl or ⌘ + Home / End | First and last cell of the table |
PageUp / PageDown | Ten rows up or down |
Space | Toggles the row's selection, where the table has one |
Enter | The table's onRowOpen |
Board
A Board's cards are one tab stop, as on Linear: the AgentTaskBoard's cards take part through TaskCard, and a card of your own through <BoardCard id render={<Button …/>} /> on its primary control. Tab from the focused card reaches that card's own controls (links, chips, approve and reject), then leaves the board; the other cards' controls are out of the tab order until their card is focused. A move renders two cards.
| Key | Does |
|---|---|
↓ or j / ↑ or k | Next and previous card in the column |
← / → | The next column, at the same row or its last card |
Home / End | First and last card of the column |
Ctrl or ⌘ + Home / End | First and last card of the board |
Enter | Opens the card |
Agents don't use these keys: they select and act on cards and rows through the board's and the table's own actions, whether or not the card or row has focus.
Virtualization
List with items and renderItem, and DataTable, render only the rows in view past 200 rows (virtualize="auto"; true or false to force it, estimateSize for the row height before it is measured; the first row measured sets it for the rest). It uses UI SDK's virtualizer and renders again only when the rows in view change, not on every scroll.
- They scroll with their nearest scrolling ancestor, or the window when there is none. Give a list a bounded height (a flex child with
min-h-0andoverflow-auto, or amax-h-*). - Rows stay in document flow: gaps take the place of the rows between, so a table keeps
tbody > trand a listul > li. List rows carryaria-setsizeandaria-posinset; table rowsaria-rowindexunder the table'saria-rowcount. - Every row is reachable: Home, End and the page keys scroll a row in before focus moves, and the focused row stays rendered while you scroll away. Agents'
selectandsetSelectiontake any row's id. - Find in page reaches rows that aren't rendered: their text sits in
hidden="until-found"elements, and finding one scrolls the real row in. Browsers withoutuntil-foundfind only the rendered rows. - Card lists and grouped lists don't virtualize: render fewer cards, or page them.
CommitHistoryandGitTreeshare their rows through thetrail-rowsitem:useTrailRowsisuseVirtualRowsby default, and withfindableputs rows on UI SDK's virtualizer so find in page reaches rows that aren't rendered.