feat: Reorderable tabs (reorder, pinned, add-tab, cross-list)#4709
Draft
ernst-dev wants to merge 3 commits into
Draft
feat: Reorderable tabs (reorder, pinned, add-tab, cross-list)#4709ernst-dev wants to merge 3 commits into
ernst-dev wants to merge 3 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds opt-in tab reordering to the
Tabscomponent, reusing the existing@dnd-kitSortableArea/InternalDragHandlestack already shipped forList. Four capabilities, all additive and opt-in:reorderable+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.Tab.disableReorderkeeps individual tabs fixed while the rest reorder around them.addTabButton+onAddTabrender and handle a trailing add-tab ("+") control.reorderGroup+onTabMove(TabMoveDetail). Two or morereorderableTabsthat share the same non-emptyreorderGroupcan exchange tabs with no wrapper or provider. EachTabskeeps its ownDndContext; coordination happens through a module-levelAsyncStoreregistry. SupportsCtrl+Arrow keyboard transfer between lists and a geometry hit-test for pointer transfer via public@dnd-kitcallbacks.onTabMoveis a controlled event — the consumer updates both lists'tabsarrays (remove from source, insert into target); it fires on both instances involved.Listand provider-less (non-reorderGroup)Tabsbehavior 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 newi18nStringsreorder/cross-list live-announcement keys.Accessibility
reorderGroup:Ctrl+Arrow transfers the lifted tab into the adjacent list (also RTL-aware).liveAnnouncementTabMovedAcrossListsstring announces the moved tab's target position and total in the destination list.role="application"— the header switches torole="application"while reordering is active so the arrow-key interaction model is conveyed to assistive tech, and reverts afterward.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):
tscclean.eslintclean;stylelintclean (both run via the pre-commitlint-stagedhook).internal/components/sortable-area,list, andtabs— including the newcross-list-move,reorder-group-registry(registry lifecycle), andcross-list-reordersuites.List/SortableAreabehavior intact (their suites still green).Not yet done (honest status):
Reviewers can exercise the cross-list behavior via the new dev page
pages/tabs/cross-list.page.tsx(tworeorderableTabs sharing areorderGroup), and run the unit tests with the Tabs / sortable-area / list Jest suites.Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
i18nStringskeys. Customer-facing website Usage-tab docs are still pending.Listand provider-lessTabsare unchanged. SeeCONTRIBUTING.md.@dnd-kitSortableArea/InternalDragHandlestack already shipped forList; no new browser APIs. SeeCONTRIBUTING.md.Security
checkSafeUrlfunction. — N/A: this change does not handle URLs.Testing
cross-list-move,reorder-group-registry, andcross-list-reordersuites.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.