react / react/react

input[type='number'] value isn't updated

Open
#13,651 11 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component: DOM Type: Needs Investigation
Dominant language
JavaScript
Stars
251k
Forks
51.4k
Avg merge
2d 4h
Merged PRs (30d)
53

Description

Do you want to request a feature or report a bug?
bug
What is the current behavior?
when I enter "01" into input[type=number],I set the value to 1, but it doesn't work. It still show "01"

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:

https://codesandbox.io/s/20ywk1x71n

What is the expected behavior?
when I enter "01", it should show "1"

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
15.6.2. I think it should update in "updatewrapper" in https://github.com/facebook/react/blob/master/packages/react-dom/src/client/ReactDOMInput.js.

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

Reproduce the behavior using the linked CodeSandbox with React 15.6.2, then inspect packages/react-dom/src/client/ReactDOMInput.js, especially updateWrapper as suggested in the issue. Confirm that changing the controlled value from "01" to 1 updates the displayed number input to "1" without regressing other number-input behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.