[number field] Reduce bundle size - #5220
Merged
Merged
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,212.13 ms +31.24 ms(+2.6%) | Renders: 78 (+0) | Paint: 1,895.29 ms +61.32 ms(+3.3%)
13 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 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
parseNumberto use range-based regex literals and codepoint arithmetic for numeral-system normalization (plus smaller replacement structures). - Inlined
useNumberFieldButtonintouseNumberFieldStepperButtonand removed the unused visual viewport resize subscription helper. - Simplified Number Field root context shape and updated call sites to read derived flags from
stateinstead 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
marked this pull request as ready for review
July 13, 2026 10:30
atomiks
requested review from
colmtuite,
flaviendelangle,
jjenzz and
michaldudak
as code owners
July 13, 2026 10:30
atomiks
force-pushed
the
claude/number-field-simplify-cef779
branch
from
July 13, 2026 14:07
55b0929 to
49a966d
Compare
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.
Reduces the
@base-ui/react/number-fieldbundle 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.