AddThisFeature

Roving Tabindex Utility

Give composite widgets one tab stop, with arrow keys moving inside them.

involved Components & Primitives

What it adds

A shared keyboard-navigation behaviour for toolbars, tab strips, menus, option lists, and grids.

What your agent is told to do

5
  1. 1

    Find the composite widgets where the keyboard currently steps through every child — toolbars, tab strips, menus, segmented controls, option lists, calendar grids, card grids — and give each a single tab stop with arrow keys operating inside it.

  2. 2

    Track the active item by stable identity rather than by index, so items appearing, disappearing, or being reordered cannot move the active position onto an unrelated control.

  3. 3

    Support the orientations these widgets genuinely take: a horizontal row, a vertical list, and a two-dimensional grid where up and down move between rows. Include Home and End, and decide explicitly whether the ends wrap.

  4. 4

    Skip hidden and unavailable items when moving, and if the active item disappears, move to the nearest remaining one rather than leaving the widget with no tab stop at all.

  5. 5

    Do not simply remove every child from the tab order and hope focus is managed elsewhere. Exactly one item must be reachable by tab at any moment, and returning to the widget must land on the item the user left rather than the first one. Which item is focused belongs here; which items are selected belongs to Selection State Pattern, and the two must be free to differ.

Edge cases it handles

7
  • An active item that is filtered out, collapsed, or removed leaves the widget with nothing focusable, and the next tab press lands somewhere unrelated on the page.
  • In a grid, arrow keys must move by row and column rather than through a flattened list, and rows of unequal length need a defined behaviour at the short end.
  • A list that re-renders after a fetch or a filter must keep the same item active. Restoring by index quietly moves focus to a different control.
  • Exactly one item carries the tab stop at any moment; letting two claim it produces a widget that is entered twice, and letting none claim it produces one that cannot be entered at all.
  • Typing a letter in a menu or option list is expected to jump to the matching item, and that typeahead must not collide with a search field inside the same widget.
  • Arrow keys pressed inside a text input or a native select belong to that control, so the utility has to yield rather than intercepting them.
  • Moving the active item must scroll it into view within its own scrolling container without dragging the whole page along with it.

Definition of done

9
  • Each composite widget occupies exactly one stop in the tab order.
  • Arrow keys, Home, and End move between items within a widget.
  • The active item is tracked by identity and survives re-renders, sorting, and filtering.
  • Hidden and unavailable items are skipped, and losing the active item never leaves the widget unreachable.
  • Returning to a widget by tab restores the item the user last had active.
  • Horizontal, vertical, and grid arrangements are all supported.
  • Focus and selection are represented separately and may point at different items.
  • The feature matches the existing design system.
  • No existing functionality is broken.

Related features

How it works

  1. 1

    Copy the link

    Grab the Markdown instruction URL for this feature.

  2. 2

    Give it to your AI

    Paste it into Claude Code, Cursor, v0, Lovable — whatever you build with.

  3. 3

    It inspects, then implements

    Your agent reads your existing app first, then adds the feature to fit it.

Works with your stack

These instructions are written to adapt. They tell the agent to detect your framework, match your existing design system, and reuse what you already have — rather than assuming a particular stack.

Need it tighter than that? Customize the feature and tell it exactly what you're running.