Skip to content

Commit

Permalink
fix(NumberInput): allow value to be outside min/max, show validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tw15egan committed Jul 6, 2021
1 parent b551c07 commit bcc7f84
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/react/src/components/NumberInput/NumberInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class NumberInput extends Component {
translateWithId: (id) => defaultTranslations[id],
};

static getDerivedStateFromProps({ min, max, value }, state) {
static getDerivedStateFromProps({ value }, state) {
const { prevValue } = state;

if (useControlledStateWithValue && value === '' && prevValue !== '') {
Expand All @@ -214,10 +214,12 @@ class NumberInput extends Component {

// If `useControlledStateWithValue` feature flag is on, do nothing here.
// Otherwise, do prop -> state sync with "value capping".
//// Value capping removed in #8965
//// value: capMax(max, capMin(min, value)), (L223)
return useControlledStateWithValue || prevValue === value
? null
: {
value: capMax(max, capMin(min, value)),
value,
prevValue: value,
};
}
Expand Down

0 comments on commit bcc7f84

Please sign in to comment.