primefaces / primefaces/primereact
InputNumber: Improve allowEmpty behaviour
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 8.3k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
Current behavior
If the allowEmpty prop is false for InputNumber, the blank input will instantly be replaced by 0 with cursor behind it, which create UX problems.

Expected behavior
Input should not be changed while it is focused.
Either:
- Provide another prop to replace null values on validation.
- Add 0 only after validation (onValueChange).
Minimal reproduction of the problem with instructions
https://codesandbox.io/s/primereact-inputnumberbugs-tqb7z
Input #3
Please tell us about your environment:
-
React version:
17.01 -
PrimeReact version:
7.1.0 -
Browser:
Chrome 96.0.4664.93 -
Language: TS 3.3.3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the InputNumber component and reproduce the Input #3 case in the linked CodeSandbox using allowEmpty=false. Check the focused blank-input behavior and decide whether replacement should occur during validation or onValueChange. Done means the focused input is not immediately replaced by 0 and the chosen behavior is covered by a regression check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100