Describe the bug
Describe the bug
When InputNumber is used with a locale that formats digits as non-ASCII characters
(e.g. bn / Bengali, which formats 1 as ১), typing the digit 1 as the very
first character of an empty field produces onValueChange with value: null instead
of value: 1. All subsequent keystrokes work normally. The same bug affects every
digit on first keystroke for any locale whose numeral system does not include ASCII
digits.
Root cause
getPrefixExpression() and getSuffixExpression() extract the prefix/suffix by
calling formatter.format(1) and splitting on the ASCII string '1':
prefixChar.current = formatter.format(1).split('1')[0];
suffixChar.current = formatter.format(1).split('1').pop();
For Bengali locale, format(1) returns '১' (U+09E7). That string contains no
ASCII '1', so .split('1')[0] returns the entire value '১' as the prefix.
parseValue() then strips this "prefix" from the typed string, leaving an empty
string that evaluates to null.
Affected locales
Any locale where new Intl.NumberFormat(locale).format(1) does not contain ASCII
'1' — including but not limited to: bn, ar, ar-EG, ne, mr, as, my.
Environment
- PrimeReact version: 10.x (confirmed with current
main)
- Browsers: all (pure JS logic)
Reproducer
No response
System Information
System:
OS: Linux 6.8 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat)
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Memory: 3.99 GB / 15.33 GB
Container: Yes
Shell: 5.2.21 - /bin/bash
Binaries:
Node: 24.12.0 - /usr/local/bin/node
Yarn: 1.22.22 - /usr/bin/yarn
npm: 11.12.1 - /usr/local/bin/npm
pnpm: 10.21.0 - /usr/local/bin/pnpm
Browsers:
Chromium: 146.0.7680.164
Firefox: 148.0.2
Firefox Developer Edition: 148.0.2
npmPackages:
primereact: ^10.9.7 => 10.9.7
react: ^18.3.1 => 18.3.1
Steps to reproduce the behavior
<InputNumber locale="bn" allowEmpty onValueChange={(e) => console.log(e.value)} />
- Render the component above.
- Focus the empty input.
- Press the key
1.
- Observe:
onValueChange fires with value: null.
Expected behavior
onValueChange should fire with value: 1 on the first keystroke.
Describe the bug
Describe the bug
When
InputNumberis used with a locale that formats digits as non-ASCII characters(e.g.
bn/ Bengali, which formats1as১), typing the digit1as the veryfirst character of an empty field produces
onValueChangewithvalue: nullinsteadof
value: 1. All subsequent keystrokes work normally. The same bug affects everydigit on first keystroke for any locale whose numeral system does not include ASCII
digits.
Root cause
getPrefixExpression()andgetSuffixExpression()extract the prefix/suffix bycalling
formatter.format(1)and splitting on the ASCII string'1':For Bengali locale,
format(1)returns'১'(U+09E7). That string contains noASCII
'1', so.split('1')[0]returns the entire value'১'as the prefix.parseValue()then strips this "prefix" from the typed string, leaving an emptystring that evaluates to
null.Affected locales
Any locale where
new Intl.NumberFormat(locale).format(1)does not contain ASCII'1'— including but not limited to:bn,ar,ar-EG,ne,mr,as,my.Environment
main)Reproducer
No response
System Information
System: OS: Linux 6.8 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat) CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz Memory: 3.99 GB / 15.33 GB Container: Yes Shell: 5.2.21 - /bin/bash Binaries: Node: 24.12.0 - /usr/local/bin/node Yarn: 1.22.22 - /usr/bin/yarn npm: 11.12.1 - /usr/local/bin/npm pnpm: 10.21.0 - /usr/local/bin/pnpm Browsers: Chromium: 146.0.7680.164 Firefox: 148.0.2 Firefox Developer Edition: 148.0.2 npmPackages: primereact: ^10.9.7 => 10.9.7 react: ^18.3.1 => 18.3.1Steps to reproduce the behavior
1.onValueChangefires withvalue: null.Expected behavior
onValueChangeshould fire withvalue: 1on the first keystroke.