Skip to content

[number field] Reduce bundle size - #5220

Merged
atomiks merged 3 commits into
mui:masterfrom
atomiks:claude/number-field-simplify-cef779
Jul 13, 2026
Merged

[number field] Reduce bundle size#5220
atomiks merged 3 commits into
mui:masterfrom
atomiks:claude/number-field-simplify-cef779

Conversation

@atomiks

@atomiks atomiks commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

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

This simplifies numeral parsing, folds the stepper-button behavior into one hook, removes dead utilities and context members, and adds interaction regressions for the affected paths.

@atomiks atomiks added component: number field Changes related to the number field component. performance labels Jul 13, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 13, 2026

Copy link
Copy Markdown

commit: 49a966d

@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 ▼-2.39KB(-0.52%) ▼-686B(-0.46%)

Details of bundle changes

Performance

Total duration: 1,212.13 ms +31.24 ms(+2.6%) | Renders: 78 (+0) | Paint: 1,895.29 ms +61.32 ms(+3.3%)

Test Duration Renders
Tooltip mount (300 contained roots) 51.48 ms 🔺+8.63 ms(+20.1%) 1 (+0)

13 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 49a966d
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a54f1339c4f500009550fd6
😎 Deploy Preview https://deploy-preview-5220--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.

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

This PR reduces the @base-ui/react/number-field bundle size by simplifying and inlining internal Number Field utilities while preserving existing behavior, public API, and locale-aware parsing/formatting.

Changes:

  • Reworked parseNumber to use range-based regex literals and codepoint arithmetic for numeral-system normalization (plus smaller replacement structures).
  • Inlined useNumberFieldButton into useNumberFieldStepperButton and removed the unused visual viewport resize subscription helper.
  • Simplified Number Field root context shape and updated call sites to read derived flags from state instead of duplicating fields.

Reviewed changes

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

Show a summary per file
File Description
packages/react/src/number-field/utils/validate.ts Switches toValidatedNumber to a positional signature and simplifies step snapping.
packages/react/src/number-field/utils/validate.test.ts Adds an adapter to keep existing object-fixture style tests while exercising the new signature.
packages/react/src/number-field/utils/subscribeToVisualViewportResize.ts Removes the helper in favor of reading visualViewport.scale on demand.
packages/react/src/number-field/utils/parse.ts Collapses numeral tables/maps and runtime RegExp construction into smaller regex literals + arithmetic-based digit mapping.
packages/react/src/number-field/scrub-area/NumberFieldScrubArea.tsx Replaces subscription-based visual viewport scaling with a direct visualViewport?.scale read during cursor updates.
packages/react/src/number-field/root/useNumberFieldStepperButton.ts Inlines the single-consumer stepper button logic (previously useNumberFieldButton).
packages/react/src/number-field/root/useNumberFieldButton.ts Deletes the now-inlined hook implementation.
packages/react/src/number-field/root/NumberFieldRootContext.ts Removes write-only / duplicated members from the root context interface.
packages/react/src/number-field/root/NumberFieldRoot.tsx Updates validation call to the new toValidatedNumber signature and simplifies input-reason detection and key collection.
packages/react/src/number-field/input/NumberFieldInput.tsx Switches to reading flags/values from state and replaces stopEvent with equivalent inline calls.
packages/react/src/internals/usePressAndHold.ts Removes unused readOnly parameter and simplifies pointer-move tracking.

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

@atomiks
atomiks marked this pull request as ready for review July 13, 2026 10:30
@atomiks
atomiks force-pushed the claude/number-field-simplify-cef779 branch from 55b0929 to 49a966d Compare July 13, 2026 14:07
@atomiks
atomiks merged commit 53a6b4c into mui:master Jul 13, 2026
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: number field Changes related to the number field component. performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants