Skip to content

[slider] Reduce bundle size#5222

Merged
atomiks merged 2 commits into
mui:masterfrom
atomiks:claude/slider-simplifications-9255b6
Jul 13, 2026
Merged

[slider] Reduce bundle size#5222
atomiks merged 2 commits into
mui:masterfrom
atomiks:claude/slider-simplifications-9255b6

Conversation

@atomiks

@atomiks atomiks commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Reduces the @base-ui/react/slider bundle size without changing behavior or the public API. The bundle bot is authoritative for the current size impact.

The cleanup consolidates control, indicator, thumb, root, and collision-resolution logic. Focused state-machine and enum-sync regressions cover the affected behavior and inlined state-attribute strings.

@atomiks atomiks added component: slider Changes related to the slider component. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. labels Jul 13, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 13, 2026

Copy link
Copy Markdown

commit: cc75648

@code-infra-dashboard

code-infra-dashboard Bot commented Jul 13, 2026

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react ▼-1.96KB(-0.43%) ▼-384B(-0.26%)

Details of bundle changes

Performance

Total duration: 1,214.19 ms -83.31 ms(-6.4%) | Renders: 78 (+0) | Paint: 1,889.27 ms -109.54 ms(-5.5%)

Test Duration Renders
Scroll Area mount (300 instances) 75.64 ms ▼-23.97 ms(-24.1%) 3 (+0)
Tooltip mount (300 contained roots) 43.27 ms ▼-12.10 ms(-21.9%) 1 (+0)
Dialog mount (300 instances) 44.74 ms ▼-11.42 ms(-20.3%) 1 (+0)

11 tests within noise — details


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit cc75648
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a54f32c4ec86600086b816f
😎 Deploy Preview https://deploy-preview-5222--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks atomiks added performance and removed type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. labels Jul 13, 2026
@atomiks
atomiks force-pushed the claude/slider-simplifications-9255b6 branch 4 times, most recently from f75addb to 2897012 Compare July 13, 2026 11:08
@atomiks
atomiks marked this pull request as ready for review July 13, 2026 11:09
@atomiks
atomiks requested a review from Copilot July 13, 2026 12:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Behavior-preserving bundle-size reduction pass over @base-ui/react/slider by simplifying small helpers, removing a couple of thin utility wrappers, and switching a few internal hot-path helpers to positional arguments to improve minification. The PR also adds targeted regression tests around swap behavior, indicator parity, and interaction-state cleanup.

Changes:

  • Simplify/inline slider internal utilities (map/loops, remove tiny helpers, reuse shared mappings).
  • Convert internal helper APIs (resolveThumbCollision, getPushedThumbValues, getMidpoint) to smaller positional signatures and update call sites/tests.
  • Add regression tests for swap focus/active index, indicator parity across orientations/directions, enum-to-runtime alignment, and controlled-range growth mid-drag.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/react/src/slider/value/SliderValue.tsx Simplifies formatting and htmlFor construction for smaller output rendering.
packages/react/src/slider/utils/valueArrayToPercentages.ts Removes unused/duplicative utility to reduce bundle surface (file deleted).
packages/react/src/slider/utils/validateMinimumDistance.ts Replaces array allocation + Math.min(...distances) with early-exit loop.
packages/react/src/slider/utils/resolveThumbCollision.ts Switches to positional args, hoists shared work, and fast-paths push.
packages/react/src/slider/utils/resolveThumbCollision.test.ts Updates tests to match new resolveThumbCollision signature.
packages/react/src/slider/utils/replaceArrayItemAtIndex.ts Removes thin wrapper in favor of local inlining (file deleted).
packages/react/src/slider/utils/getSliderValue.ts Inlines array update/sort logic and simplifies non-range return path.
packages/react/src/slider/utils/getPushedThumbValues.ts Switches to positional args to improve minification.
packages/react/src/slider/utils/getPushedThumbValues.test.ts Updates tests to match new getPushedThumbValues signature.
packages/react/src/slider/utils/getMidpoint.ts Removes Coords object allocation; returns a single axis midpoint.
packages/react/src/slider/thumb/SliderThumb.tsx Reduces branching and allocations; inlines data-index; updates midpoint usage.
packages/react/src/slider/root/stateAttributesMapping.ts Reuses a shared nullMapping function to shrink mapping literals.
packages/react/src/slider/root/SliderRootContext.ts Removes unused pressedInputRef from context surface.
packages/react/src/slider/root/SliderRoot.tsx Simplifies equality check and trims memo dependencies while preserving stability.
packages/react/src/slider/root/SliderRoot.test.tsx Adds browser-mode regressions for swap focus/active index and cancel behavior.
packages/react/src/slider/indicator/SliderIndicator.tsx Consolidates style computation into a single helper while preserving behavior.
packages/react/src/slider/indicator/SliderIndicator.test.tsx Adds browser-mode parity coverage for keyboard behavior + indicator styling.
packages/react/src/slider/enumSync.test.tsx Ensures runtime data-index matches the docs enum value.
packages/react/src/slider/control/SliderControl.tsx Updates collision/midpoint calls, reduces cached refs, and tightens swap focusing.
packages/react/src/slider/control/SliderControl.test.tsx Adds browser-mode regression to ensure cached interaction state is cleared on range growth mid-drag.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@atomiks
atomiks force-pushed the claude/slider-simplifications-9255b6 branch from 3281639 to cc75648 Compare July 13, 2026 14:16
@atomiks
atomiks merged commit 8cbbf88 into mui:master Jul 13, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: slider Changes related to the slider component. performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants