fix(InputNumber): added "required" prop which is present in wrapped component (InputText) already #7063
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When used in a standard HTML
<form>
element, arequired
tag is only recognized by theInputText
component and not by theInputNumber
component.Solution
Since the
InputNumber
component is simply a wrapper around theInputText
component, which itself supports therequired
prop, this is a very straightforward fix of simply accepting and passing the props on to the wrapped components.Existing Functionality
The
allow-empty
prop tackles this from a different direction, however it resets the input field to 0 if emptied, which is a separate behaviour. Therequired
tag is recognized and validated natively by browsers, so it should be a part of all input fields, which is why this functionality is essential.