Repository navigation
fix(NumberInput): drop U+00B7 from the separator alphabet, and say what the parser actually does - #5468
Merged
Conversation
…he parser does Post-merge audit of #5459. - The file docblock still promised that anything with two readings refuses. It does not: where both a grouping and a decimal reading are well formed the locale's wins, so de-DE `1.234` is 1234 and `1.2345` is 1.2345. Say so. - U+00B7 was in the alphabet as the Catalan middle dot. Catalan groups with a full stop; walking the 136 locales Intl serves finds no locale that writes a middle dot between digits. Remove it and pin the refusal. - The changeset read as though a structured non-number is now refused. The alphabet bounds characters, not shapes: `192.168.100.200` still commits. Corpus also gains the fr-FR half of the ambiguity rule.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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 |
…dead U+00B7 test Review of #5468. - The stated rule ignored readUnder's leading-chunk guard, so it got de-DE `1234.567` and en-US `1234,567` wrong in both directions. Stated as code it disagreed with the parser on 8 of 17 inputs; it now says every group has to fit the locale's sizes, and names the cross-locale reading it also omitted. probe-kit/numberparser-docblock-rule.mjs: 0 of 35 hand-picked and 0 of 6300 generated inputs disagree. - isGroupOnlySeparator still matched U+00B7. Dead — NUMBER_BODY rejects it first — but it sat under the paragraph saying the character was removed. - The sweep behind the alphabet is every language ICU resolves in every region, not a hand-written 136. That walk finds a seventh character, U+060C (nqo), which the alphabet still leaves out. Wording only. - The ar-SA row claimed the localized separator is what makes the round trip hold. It is not: the plain `String` spelling round trips too. Say the real reason — the digits are what the field shows at rest.
… it stopped saying Review round 2 of #5468. - The rule paragraph under-predicted a space or apostrophe, which groups after ONE occurrence: en-US `1 234` is 1234 and the corpus asserts it. Add the clause. - The out-of-repo probe reported zero disagreements because its prediction borrowed `isGroupOnlySeparator`'s own rule from the implementation while claiming to implement the sentence. A grader that borrows from the thing it grades cannot fail. numberParser.docblock.test.ts is derived only from the words: each branch names the clause it implements, and those clauses are asserted verbatim against the source, so a paragraph that loses one fails here. 32,550 generated inputs, zero disagreements. - "text no reading fits" was missing a "that". The grader re-derives the locale's symbols from Intl, so it goes on the no-raw-intl-locale test-oracle allowlist with its own rule test.
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.
Post-merge audit of #5459 found three non-blocking defects. Two are documentation — the module says things the code does not do — and one is a character in the separator alphabet that no locale writes.
The docblock promised refusal where the parser now prefers.
numberParser.tsstill said anything that could mean two different numbers returns null. Since #5459 it does not: where a grouping and a decimal reading are both well formed, the locale's reading wins. In de-DE1.234is 1234 and1.2345is 1.2345 — a 1000× step between two adjacent inputs, with nothing on screen to say why. The behaviour is right and unchanged; it matches the precedent inutils/dateParser.ts("for ambiguous numeric formats, uses locale preference"), and raising the threshold would refuse the commonest paste in that locale.The rule as now stated is that grouping is well formed only when every group fits the locale's own sizes —
readUnderguards the leading and inner chunks as well as the last — plus the cross-locale reading, where three-digit groups are grouping in any locale, and the group-only separators (space, apostrophe) that need just one occurrence because no locale writes them as a decimal point.And the rule is executable.
numberParser.docblock.test.tsimplements the paragraph as code and grades it against the parser, input by input. It is derived only from the words: every branch names the clause it implements, and those clauses are asserted verbatim against the source, so a paragraph that loses one fails here rather than drifting. 32,550 generated inputs, zero disagreements, and the sweep was checked against mutations in both directions — a parser that changes without the words, and words that lose a clause, each turn it red.U+00B7 was in the alphabet as "the Catalan middle dot". Catalan groups with a full stop —
Intl.NumberFormat('ca').format(1234567.5)is1.234.567,5. Sweeping every language ICU resolves in every region and collecting every character emitted asgroupordecimal, before and after NFKC, yields exactly seven:,.'U+0020 U+066B U+066C and U+060C, the last written only by nqo and deliberately still not admitted. (U+00A0 and U+202F appear and need no entry — NFKC folds both to U+0020 before the alphabet is consulted.) U+2019 appears in no locale but stays: the corpus pins it as the Swiss spelling. U+00B7 has no such defence, so it is gone from the alphabet and from the now-dead branch inisGroupOnlySeparator, and1·234·567refuses.The changeset claimed more than the fix delivers. It read as though pasting a structured non-number into a quantity field is now refused. It is not: the alphabet bounds characters, not shapes, so
192.168.100.200commits 192168100200 on a plain en-US field — measured identical under this parser and under #5459's, so pre-existing and not fixed here. The wording is corrected; the code is untouched.Also: the corpus gains the fr-FR half of the ambiguity rule (
1.234is 1.234 there, because fr-FR groups with a space, not a full stop — measured), and the[3.5, 'ar-SA', '3٫5']row now says why. Its first explanation was itself an over-claim: the plainStringspelling round trips just as well. The real reason is that Latin digits are what the field shows at rest, so localizing them would flip the script on focus — rendered at rest and on focus to confirm it.Risk. One behaviour change: text spelled with U+00B7 no longer parses. Nothing else moves — every one of the 95 corpus rows was run under this parser and under main's, and 93 are byte-identical, the two middle-dot rows being the intended difference. No API change,
formatValueuntouched. The new grader re-derives the locale's symbols fromIntl, so it joins theno-raw-intl-localetest-oracle allowlist with its own focused rule test;raw-import.d.tstypes the?rawimport it reads its subject with.Testing. 261 tests in
packages/core/src/NumberInputpass, plus the rule's own suite. #5110's four regressions were re-driven in real Chromium against Storybook — Arabic-Indic١٢٣typed and pasted,1,5in de-DE, full-width123through CDP composition both stepwise and committed, and therole="alert"announcement, which now also fires for1·234·567.@cixzhang