Skip to content

feat: Reorderable tabs (reorder, pinned, add-tab, cross-list)#4709

Draft
ernst-dev wants to merge 3 commits into
mainfrom
dev-v3-ernstka-reorderable-tabs
Draft

feat: Reorderable tabs (reorder, pinned, add-tab, cross-list)#4709
ernst-dev wants to merge 3 commits into
mainfrom
dev-v3-ernstka-reorderable-tabs

Conversation

@ernst-dev

Copy link
Copy Markdown
Member

Description

Adds opt-in tab reordering to the Tabs component, reusing the existing @dnd-kit SortableArea / InternalDragHandle stack already shipped for List. Four capabilities, all additive and opt-in:

  1. Within-list reorderreorderable + onReorder({ tabIds }). Pointer drag and full keyboard support (Space/Enter to lift, arrow keys to move — RTL-aware, Esc to cancel), with live-region announcements.
  2. Pinned / position-locked tabsTab.disableReorder keeps individual tabs fixed while the rest reorder around them.
  3. Add-tab affordanceaddTabButton + onAddTab render and handle a trailing add-tab ("+") control.
  4. Provider-less cross-list dragreorderGroup + onTabMove(TabMoveDetail). Two or more reorderable Tabs that share the same non-empty reorderGroup can exchange tabs with no wrapper or provider. Each Tabs keeps its own DndContext; coordination happens through a module-level AsyncStore registry. Supports Ctrl+Arrow keyboard transfer between lists and a geometry hit-test for pointer transfer via public @dnd-kit callbacks. onTabMove is a controlled event — the consumer updates both lists' tabs arrays (remove from source, insert into target); it fires on both instances involved.

List and provider-less (non-reorderGroup) Tabs behavior is unchanged — everything new is gated behind the new optional props.

New public API surface: TabsProps.reorderable, TabsProps.onReorder, TabsProps.Tab.disableReorder, TabsProps.addTabButton, TabsProps.onAddTab/AddTabDetail, TabsProps.reorderGroup, TabsProps.onTabMove/TabMoveDetail, plus new i18nStrings reorder/cross-list live-announcement keys.

Accessibility

  • Keyboard model — within a list: Space/Enter lifts a tab, arrow keys move it (RTL-aware), Esc cancels and restores the original position. Across lists in the same reorderGroup: Ctrl+Arrow transfers the lifted tab into the adjacent list (also RTL-aware).
  • Live-region announcements — grab/move/commit/cancel are announced within a list; a dedicated liveAnnouncementTabMovedAcrossLists string announces the moved tab's target position and total in the destination list.
  • role="application" — the header switches to role="application" while reordering is active so the arrow-key interaction model is conveyed to assistive tech, and reverts afterward.
  • Focus / selection handoff — the moved tab keeps focus and selection across the list boundary during a cross-list move so keyboard users don't lose their place.
  • Reduced motion — drag/reorder transitions respect prefers-reduced-motion.

Related links, issue #, if available: API proposal (Chorus): https://chorus.aws.dev/doc/dB5QkUyuhbqU

How has this been tested?

Local verification on this branch (Node 24):

  • Type-check: tsc clean.
  • Lint: eslint clean; stylelint clean (both run via the pre-commit lint-staged hook).
  • Unit tests: Tabs suite 107 / 107 passing.
  • Full suite: 177 / 177 across 14 suites covering internal/components/sortable-area, list, and tabs — including the new cross-list-move, reorder-group-registry (registry lifecycle), and cross-list-reorder suites.
  • Regression: existing List / SortableArea behavior intact (their suites still green).

Not yet done (honest status):

  • WebDriver / integration (motion + real-DOM drag) tests — not yet written or run.
  • Public API sign-off — PENDING. The new props/events above still need design + API review before this can leave draft.

Reviewers can exercise the cross-list behavior via the new dev page pages/tabs/cross-list.page.tsx (two reorderable Tabs sharing a reorderGroup), and run the unit tests with the Tabs / sortable-area / list Jest suites.

Note: per CONTRIBUTING.md, this repository currently accepts external code contributions only for bug fixes, and changes are expected to come from a fork against main. This is a feature opened as a draft for internal review and public API sign-off — not a ready-to-merge external contribution.

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates. — In-code JSDoc added for every new public prop/interface and new i18nStrings keys. Customer-facing website Usage-tab docs are still pending.
  • Changes are backward-compatible — every new prop is optional and opt-in; List and provider-less Tabs are unchanged. See CONTRIBUTING.md.
  • Changes do not include unsupported browser features — reuses the existing @dnd-kit SortableArea/InternalDragHandle stack already shipped for List; no new browser APIs. See CONTRIBUTING.md.
  • Changes were manually tested for accessibility — keyboard model and live-region announcements are implemented and covered by unit tests; a full manual screen-reader / AT sweep is still pending. See accessibility guidelines.

Security

  • If the code handles URLs: all URLs are validated through the checkSafeUrl function. — N/A: this change does not handle URLs.

Testing

  • Changes are covered with new/existing unit tests? — Tabs 107/107; 177/177 across 14 suites, incl. new cross-list-move, reorder-group-registry, and cross-list-reorder suites.
  • Changes are covered with new/existing integration tests? — WebDriver/integration tests not yet added or run.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

ernst-dev added 2 commits July 8, 2026 10:15
Adds opt-in tab reordering to the Tabs component, reusing the existing @dnd-kit SortableArea/InternalDragHandle stack.

- reorderable + onReorder({tabIds}) — pointer + keyboard (Space/Enter lift, arrows move RTL-aware, Esc cancel), live announcements
- Tab.disableReorder — pinned/position-locked tabs
- addTabButton + onAddTab — add-tab (+) affordance
- reorderGroup + onTabMove(TabMoveDetail) — provider-less cross-list drag: same-reorderGroup Tabs exchange tabs via a module-level AsyncStore registry (each Tabs keeps its own DndContext; Ctrl+Arrow keyboard transfer; geometry hit-test for pointer via public @dnd-kit callbacks)

List and provider-less Tabs unchanged. tsc + eslint clean; Tabs 107/107; 177/177 across sortable-area/list/tabs suites.
@ernst-dev ernst-dev changed the title feat(tabs): reorderable tabs (reorder, pinned, add-tab, cross-list) feat: Reorderable tabs (reorder, pinned, add-tab, cross-list) Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant