Repository navigation
fix(NumberInput): parse pasted grouped and localized numbers - #5450
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
cixzhang
marked this pull request as ready for review
August 24, 2026 23:43
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsNumberInput (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
cixzhang
added a commit
that referenced
this pull request
Aug 25, 2026
…ecimal point (#5459) #5450 decided which characters may separate digits from the input itself: unbounded for grouping, locale-only for the decimal point. Both halves are wrong, and they are the same decision. - A full stop the locale cannot read as grouping now reads as the decimal point it can only be, so de-DE 1.5 commits 1.5 again instead of 1. It is tried after the locale reading, not before it like dateParser.ts's ISO branch, because 1.234 in de-DE genuinely has two readings and grouping is the one a German means. - Only the characters some locale writes between digits are separators, so 123-456-789 is not 123456789. - An explicit sign inside accounting parens refuses instead of flipping. Every defect gets a corpus row, formatEditableNumber gets its first tests.
31 of 40 tasks
4 tasks done
cixzhang
pushed a commit
that referenced
this pull request
Oct 21, 2026
<!-- template: bug-fix.md -->
## User impact
An app that builds Astryx from source with the documented Next.js setup, but sets no browserslist or targets a browser without Unicode property escapes (such as Safari 11), fails `next build --webpack` with `Unknown property: L` (also `Zs`, `Letter`). The errors point at `Avatar.tsx`, `Markdown/parser.ts` and `Markdown/plugins/headingLinks.ts`, package source the app cannot change, and come from both the PostCSS pass and the JavaScript compile. Any import from the package root reaches them.
## Problem and solution fit
- Why it fails: with no targets, or old ones, `next/babel`'s preset-env rewrites every `\p{…}` regex literal with transform-unicode-property-regex. Next's bundled copy of that transform loads `regenerate-unicode-properties` at runtime, which Next does not ship, so it throws (Next 16.3.6 and 16.4.2 alike).
- Why it harms the task: the throw stops the whole build.
- Why that matters: the app cannot fix it in its own code, and the error names a Unicode property, not the missing target.
## Expected behavior and authority
This is a regression of a settled case. #5450 hit this failure in `NumberInput/numberParser.ts` and builds those expressions with `new RegExp(...)`; its comment records why, and notes that property escapes need no transform in any browser this package supports. #6698, #6911 and #7051 later added four new literals and reintroduced it.
## Smallest restoration
- The four literals become `new RegExp(...)` with the same pattern and flags, built once at module load as before.
- Each site's comment names the cause and when a literal is safe again: once Next's bundled Babel ships the Unicode data.
- A source-build test fails when a Core module writes a property escape as a regex literal.
## Evidence
- Reproduction before the change: a clean registry install of main's documented Next.js example (`apps/example-nextjs-source`, hoisted, browserslist removed). `next build --webpack` fails in the PostCSS pass (`Avatar.tsx: Unknown property: L`) and in the JavaScript compile (`Unknown property: L`, `Zs`, `Letter` from the three files).
- Result after the change: the same install, with this change applied to Core's source, compiles and prerenders, and all 226 rendered class names have a rule in the emitted CSS.
- Representative unchanged path: the Avatar and Markdown suites pass unchanged.
- Regression test or other mutation-sensitive proof: `unicodePropertyEscapes.source-build.test.mjs` fails on main listing the four literals, and passes here.
## Scope
- [x] One defect is restored.
- [x] Separable contradictory or unsettled tagalongs were removed or split.
- [x] No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
- [x] Public text and artifacts contain no internal Meta context.
## Testing
- `pnpm exec vitest run --project ui packages/core/src/Avatar packages/core/src/Markdown packages/core/src/unicodePropertyEscapes.source-build.test.mjs`: 50 files, 1,158 tests pass (the new test alone fails on main).
- `next build --webpack` on the clean install, no browserslist: fails on main in both passes; passes with this change (226 of 226 rendered classes have a rule).
- `pnpm -F @astryxdesign/core typecheck`, ESLint and Prettier on the touched files, `pnpm check:repo`, changeset coverage: pass.
This branch was successfully deployed
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.
What
A pasted
1,234,234,234now commits as1234234234.parseNumberInputwasNumber(trimmed).Number("1,234,234,234")isNaN, sothe field went
aria-invalidand the paste was lost — the most common wayanyone puts a large number into a form. This is the default path: no props
beyond the required ones, no
formatValue.No API change.
formatValueis untouched and does not appear in the diff.The parser
Typed and pasted text is read under the field's locale, from
useLocale().Nothing is hardcoded: the grouping and decimal separators and the group sizes
come from
Intl.NumberFormat(locale).formatToParts, so1.234.234.234inde-DE, narrow-no-break-space grouping in fr-FR and lakh grouping in en-IN all
work without a table. Digit values are derived from
\p{Nd}by walking back toeach script's zero, so Arabic-Indic, Devanagari and full-width digits parse
without a table either.
Two readings, in order:
1,5is 1.5 in de-DE.only be grouping — a decimal point appears once — so
1,234,234,234readsthe same in every locale, which is what makes the spreadsheet paste land in
a de-DE app.
Anything that could mean two different numbers returns
nulland the fieldstays visibly invalid with its existing
role="alert"announcement.1,5inen-US is nothing. Typing is never intercepted: no
beforeinputguard, nokeystroke rejection, no rewriting mid-composition. The value commits on blur.
One behaviour change outside the parser: while focused, the raw value renders
with the locale's decimal separator (de-DE shows
1,5, not1.5), so what thefield renders is what the field can read back. In en-US this is identical to
today.
The corpus
numberParser.test.tsis a single table — input, locale, expected — and it isthe specification. 72 rows: grouping shapes, lakh grouping, ragged grouping,
signs on either end, whitespace and newlines, five digit scripts, currency,
accounting negatives, typographic minus signs, exponents, BOM and zero-width
characters, and junk.
nullrows are assertions, not fallthrough.Two calls worth flagging:
$1,234.56→ 1234.56). A\p{Sc}symbolcarries no magnitude, so dropping it cannot produce a wrong number — the
separator rules still decide, and
1.234,56 €in an en-US field stillrefuses.
1,234 GB→null). A trailing letter cancarry magnitude (
k,B), so guessing which letters are inert is exactlyhow a wrong number gets committed.
Testing
jsdom does not fire
insertFromPaste. Screenshots below.tsc --noEmit✓, ESLint ✓,check:repo✓, docsitegenerate✓.numberParser.tsis on theno-raw-intl-localeapproved-implementation list(rule source + README + a focused rule test), which is the only sanctioned way
to reach
Intldirectly.Verified in real Chromium
A representative dozen, pasted with a real clipboard write +
Meta+Vagainstlocal Storybook —
NumberInput › Paste Formatted Number, also live at the PR'sStorybook preview.
"Shown while focused" is the field's own value mid-paste: the text is never
rewritten.
1,234,234,2341,234,234,234$1,234.56$1,234.56(1,234)(1,234)1<NBSP>2341 234١,٢٣٤١,٢٣٤1.23E+091.23E+091,234 GB1,234 GB1,51,51.234.234.2341.234.234.2341,51,51.234,561.234,561,234,234,2341,234,234,234The de-DE field in that story carries an ordinary
formatValue, so the fullloop is visible: paste
1,234,234,234→ field holds the pasted text whilefocused → blur → commits 1234234234 → re-renders
1.234.234.234.Docsite:
pnpm -F @astryxdesign/docsite generatethen the rendered/components/NumberInputpage — the new line is the first Best-practices row.docsZhanddocsDensewere checked through the doc loader, not assumed.