Skip to content

Resetting a form containing a focused controlled number input puts it out of step with state #11674

@aweary

Description

@aweary

Here's a fixture demonstrating the issue (first test case): http://react-number-input-form-reset-bug.surge.sh/number-inputs

If you have a controlled number input within a form containing a reset button, hitting Enter can trigger that reset event. This causes the focused input to be reset to the defaultValue, which won't be in sync with the tracked value because we do that work on blur for number inputs to avoid triggering validation warnings. This doesn't affect other input types, since the tracked value is updated immediately.

This might be a viable tradeoff for avoiding those validation warnings, so I'm not sure if this is actionable, but I wanted to at least document it for future reference.

cc @nhunzaker @gaearon

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions