[tabs][toolbar] Reduce bundle size#5221
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,198.31 ms -165.33 ms(-12.1%) | Renders: 78 (+0) | Paint: 1,870.81 ms -240.25 ms(-11.4%)
11 tests within noise — details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR reduces bundle size in the Tabs and Toolbar entrypoints by removing behavior-neutral indirections (enum/IIFE references, redundant context members) and by consolidating repeated lookup/direction logic, while keeping runtime behavior pinned by existing and new tests.
Changes:
- Toolbar: simplify separator orientation derivation, remove unused
setItemMapfromToolbarRootContext, and rely on downstream defaults for optional props. - Tabs: inline data attribute / CSS variable names (with a new test to keep them synced with docs enums), simplify tab activation/highlight wiring, and deduplicate tab element lookup + activation-direction computation.
- Composite internals: make
IndexGuessBehaviortree-shakeable and trim small dead/default code paths.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react/src/toolbar/separator/ToolbarSeparator.tsx | Simplifies derived separator orientation without enum indirection. |
| packages/react/src/toolbar/root/ToolbarRootContext.ts | Removes unused context member to trim toolbar entrypoint weight. |
| packages/react/src/toolbar/root/ToolbarRoot.tsx | Drops redundant context wiring and relies on downstream defaults for optional props. |
| packages/react/src/toolbar/link/ToolbarLink.test.tsx | Updates test context shape after context member removal. |
| packages/react/src/toolbar/input/ToolbarInput.tsx | Makes group context optional and deduplicates disabled-event prevention handlers. |
| packages/react/src/toolbar/input/ToolbarInput.test.tsx | Updates test context shape after context member removal. |
| packages/react/src/toolbar/group/ToolbarGroupContext.ts | Makes group context access always-optional to enable tree-shaking and simpler call sites. |
| packages/react/src/toolbar/group/ToolbarGroup.test.tsx | Updates test context shape after context member removal. |
| packages/react/src/toolbar/button/ToolbarButton.tsx | Makes group context optional and relies on useButton defaults for nativeButton. |
| packages/react/src/toolbar/button/ToolbarButton.test.tsx | Updates test context shape after context member removal. |
| packages/react/src/toggle-group/ToggleGroup.tsx | Makes toolbar group context optional to avoid unnecessary runtime branching. |
| packages/react/src/tabs/tab/TabsTab.tsx | Removes redundant list-context members, uses composite root highlight state, and calls onValueChange directly with guarded activation. |
| packages/react/src/tabs/root/TabsRootContext.ts | Changes panel registration to return an unsubscribe cleanup function. |
| packages/react/src/tabs/root/TabsRoot.tsx | Extracts shared tab lookup helper and consolidates activation-direction logic. |
| packages/react/src/tabs/root/stateAttributesMapping.ts | Inlines the emitted data attribute name for better tree-shaking. |
| packages/react/src/tabs/panel/TabsPanel.tsx | Simplifies panel list item registration and uses cleanup-returning panel registration. |
| packages/react/src/tabs/list/TabsListContext.ts | Removes dead/redundant context members to reduce tabs entrypoint size. |
| packages/react/src/tabs/list/TabsList.tsx | Stops re-exporting activation/highlight plumbing through list context; keeps it inside composite root usage. |
| packages/react/src/tabs/indicator/TabsIndicator.tsx | Inlines CSS variable names and slightly simplifies scale checks used for measurement. |
| packages/react/src/tabs/enumSync.test.tsx | Adds tests to keep docs enums and runtime inlined literals in sync without shipping production bytes. |
| packages/react/src/internals/composite/root/useCompositeRoot.ts | Removes small redundant defaults/returns and simplifies modifier-key iteration. |
| packages/react/src/internals/composite/list/useCompositeListItem.ts | Replaces enum with tree-shakeable const object + type alias for IndexGuessBehavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3e728a6 to
f260347
Compare
Removes behavior-neutral dead weight from the Tabs and Toolbar entry points. The bundle bot is authoritative for the current size impact.
Runtime-only enum values are inlined and pinned by enum-sync tests, redundant context members are removed, duplicated lookup and direction logic is consolidated, and the composite substrate's
IndexGuessBehaviorrepresentation is made tree-shakeable. Tabs, Toolbar, Toggle Group, and composite regressions cover the affected behavior.