Skip to content

InputNumber swallows first keystroke when locale uses non-ASCII numerals (e.g. bn) #8521

@8lurry

Description

@8lurry

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)} />
  1. Render the component above.
  2. Focus the empty input.
  3. Press the key 1.
  4. Observe: onValueChange fires with value: null.

Expected behavior

onValueChange should fire with value: 1 on the first keystroke.

Metadata

Metadata

Assignees

Labels

Type: BugIssue contains a defect related to a specific component.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions