primefaces / primefaces/primereact

InputNumber: Improve allowEmpty behaviour

Open
#2,529 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Status: Discussion
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.
strange blank behaviour

Expected behavior
Input should not be changed while it is focused.
Either:

  1. Provide another prop to replace null values on validation.
  2. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.