primefaces / primefaces/primereact

InputNumber: value doesn't respect value state

Open
#6,410 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

Describe the bug

It seems that the value prop provided to <InputNumber/> isn't always correctly used.

The user can also think he's writing a value greater than the max value, because it's checked on blur.
The value can be outdated even after component blur.

Reproducer

https://codesandbox.io/p/sandbox/charming-sea-99c8lj?file=%2Fsrc%2Fdemo%2FInputNumberDemo.js%3A28%2C21

PrimeReact version

9.3.1

React version

17.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior
  1. Select the input, its value should be 20 by default.
  2. Change value to 50.
  3. Click outside of the input. The value goes back to 30.
Expected behavior
  1. When trying to change the value, we shouldn't be able to write a value greater than max.
  2. The value in the input shouldn't change because its value prop is fixed.

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 run the linked CodeSandbox reproducer. Verify the controlled value, max handling, and blur behavior described in the reproduction steps; the issue is done when values above max cannot be entered and a fixed value prop is not overwritten after blur.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
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.