useActionRowNavigation
Provider-backed two-zone keyboard navigation for rows with inline actions. Moves between row content and action buttons while preserving disabled-action behavior.
useActionRowNavigation coordinates a row's main content with a strip of inline action buttons. It splits the row into two zones — content and actions — and wires the arrow keys so the keyboard can step into the actions, move between them, activate one, and step back out. It is built for dense list, table, inbox, review, and command-result rows.
It composes useFocusZone (the two zones) with useKey (the per-zone bindings), so it requires KeyboardProvider and is package-only.
When to use it
- A row has both a primary target (open, navigate) and secondary actions (approve, archive, delete) that should be reachable without a mouse.
- Actions live to the side of the row content and should be entered with a single arrow press, not by Tabbing through every button on the page.
- Some actions are conditionally disabled and keyboard movement must skip them rather than landing on dead controls.
For a plain list with no per-row action strip, use useNavigation or useScopedNavigation instead.
Installation
Requires KeyboardProvider and the @diffgazer/keys package, which is not public on npm yet.
Diffgazer packages are not yet published to npm. Until the first release, pack @diffgazer/ui and @diffgazer/keys from the repository and install those tarballs.
@diffgazer/keys requires no CSS or Tailwind setup.
Parameters
Returns
Keyboard behavior
When containerRef is supplied, the row only handles these keys while focus is inside that container. Omitting containerRef intentionally leaves the active row's handlers global within the current keyboard scope. Bindings register through KeyboardProvider, so they participate in the scope stack.
Examples
Review row with inline actions
Notes
Two zones, one row
The hook composes useFocusZone with a content zone and an actions zone. ArrowDown enters actions from content, ArrowUp leaves actions, and ArrowLeft/ArrowRight move between actions.
Disabled actions
Indexes flagged in disabledActions are skipped during ArrowLeft/ArrowRight movement and ignored by Enter/Space. If every action is disabled, the hook returns to content and focuses disabledFocusFallbackRef.
Scope rows with containerRef
Pass containerRef for each row so its arrow keys only fire while focus is inside that row. Omitting it intentionally leaves the active row's handlers global within the current keyboard scope.
Requires KeyboardProvider
useActionRowNavigation registers keys through useKey and useFocusZone, so it must be used within a <KeyboardProvider> tree. It is package-only.
Edge cases
- All actions disabled. Entering the actions zone with no enabled action returns focus to
disabledFocusFallbackRef, or blurs the focused action when the ref is omitted.enterActionsreturnsnullin this case. - Disabled flags change at runtime. Update
disabledActionsand the hook re-resolves the focused index on the next render; if the focused action becomes disabled it moves to the first enabled one, or leaves the zone when none remain. getActionPropsis required per action. The hook focuses and tracks actions through therefandonFocusit returns. Spread it onto every action element, including disabled ones, so indexes stay aligned.
Related
useFocusZone— the underlying two-zone primitive.useNavigation— single-zone list navigation without an action strip.useKey— the per-zone key registration this hook builds on.
Source
Highlighted source loads after this disclosure opens. Browse the source repository.