-
-
Notifications
You must be signed in to change notification settings - Fork 234
[number field] Improve parsing logic #2725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
commit: |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Bundle size report
|
f60460e
to
05d3dfb
Compare
05d3dfb
to
c535a1c
Compare
六: '6', | ||
七: '7', | ||
八: '8', | ||
九: '9', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
九: '9', | |
九: '9', | |
十: '10', |
@atomiks This is supposed to simply convert single digits?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should - let me know if that char is necessary though to handle another use case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LLM review as this is out of my depth a bit:
We intentionally only normalize single-glyph Han digits (零/〇…九). Adding 十: '10' would break inputs like 三十 (30), which would become "310" under per-char substitution. If we need full ideographic number parsing, that should be a separate parser; this function is just digit normalization across scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK it doesn't matter then if it's just converting each individual char into a digit
Though in practice this would only work for 0-9 (and not 10+) since there are characters for 10/100/1000, so the numbering system is similar to roman numerals
But this is indeed an incredibly exotic use-case so it's ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found one more bug on master - when using a locale with "." as a thousand separator and "," as a decimal point, I can't type in more than one "." (and I can type more commas)
}); | ||
|
||
it('collapses extra dots from mixed-locale inputs', () => { | ||
// First '.' is decimal; subsequent '.' are removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// First '.' is decimal; subsequent '.' are removed | |
// Last '.' is decimal; previous '.' are removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be the culprit in onKeyDown
as it doesn't pass the locale
, although it uses your runtime locale. Is it in US/English for you when the bug occurs?
const { decimal, currency, percentSign } = getNumberLocaleDetails(
[],
formatOptionsRef.current,
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, but I see you fixed it. Seems to work OK, but I found another issue 😅 - when on "pl-PL' locale (where we use spaces as thousand separators), I can't type in space at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michaldudak I see, fixed
7c72b98
to
43d3913
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I haven't found any more issues.
0010ea2
to
632c655
Compare
Handles a few more edge cases correctly.
Fixes #2735