Conversation
TabsHeader listed the tabs in the order they registered themselves, so a panel that mounted later always appeared last, no matter where it sat in the children. The new optional order prop decides the position instead. Panels without an order keep the order they mounted in, so existing consumers are unaffected. 🤖 Generated with Claude Code
There was a problem hiding this comment.
🟡 Changes recommended
Two moderate issues affect active-tab selection and order updates.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds an optional order prop to TabPanel so tab headers can be ordered independently of mount order.
Changes:
- Adds
ordertoTabPanelProps. - Sorts tab headers by order.
- Registers panel ordering metadata.
- Adds regression coverage for dynamically mounted panels.
File summaries
| File | Summary |
|---|---|
src/Tabs/types.ts |
Defines the optional order prop. |
src/Tabs/TabsHeader.tsx |
Sorts headers, but active-tab selection can still follow registration order (moderate; 1 vote). |
src/Tabs/TabPanel.tsx |
Registers ordering, but order changes can clear active selection and alter tie-breaking (moderate; 3 votes). |
src/Tabs/index.test.tsx |
Tests ordering for dynamically mounted panels. |
Review details
Suppressed comments (1)
src/Tabs/TabsHeader.tsx:50
- Sorting only the header leaves
Tabs.tsx's active-tab state in registration order. With panels mounted as 3(order 3), 1(order 1), and 2(order 2), the last visual tab is initially active; after removing the active panel 1, the reducer also falls back to the first registered remaining tab 3 instead of the first displayed tab 2. Apply the same ordering to initial/fallback selection (or keep ordered tabs in state) so selection follows the rendered order.
{sortedByOrder(context.tabs).map((tab: TabPanelProps) => {
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| }; | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| }, [props.id, props.title]); | ||
| }, [props.id, props.title, props.order]); |
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.
TabsHeaderrendered the tabs in the order they registered themselves. A panel that mounts later than its siblings therefore always ends up last, no matter where it sits in the children — e.g. a tab bar where a new panel is added next to an existing group at runtime.This adds an optional
orderprop toTabPanel.TabsHeadersorts by it, and panels without anorderkeep the order they mounted in, so existing consumers see no change.Alternative rejected: deriving the position from the children of
Tabs. Panels register themselves through the context from arbitrary depth (wrapped in providers, spinners, form wrappers), so their JSX position is not available where the header renders.The regression test uses explicit
keys on purpose — without them React reconciles the panels positionally and they re-register in the right order by accident, which makes the test pass even without the sort.🤖 Generated with Claude Code