Skip to content

Commit

Permalink
fix(NumberInput): Custom increment/decrement and thresholds
Browse files Browse the repository at this point in the history
  • Loading branch information
jenny-s51 committed Mar 31, 2022
1 parent a1d1e32 commit f18e939
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,13 @@ class CustomStepNumberInput extends React.Component {
};

this.onChange = event => {
const newValue = isNaN(event.target.value) ? 0 : Number(event.target.value);
this.setState({
value: newValue
});
};

this.onBlur = event => {
const newValue = isNaN(event.target.value) ? 0 : Number(event.target.value);
this.setState({
value: newValue > this.maxValue ? this.maxValue : newValue < this.minValue ? this.minValue : newValue
Expand All @@ -463,6 +470,7 @@ class CustomStepNumberInput extends React.Component {
max={this.maxValue}
onMinus={this.stepper(-3)}
onChange={this.onChange}
onBlur={this.onBlur}
onPlus={this.stepper(3)}
inputName="input"
inputAriaLabel="number input"
Expand Down

0 comments on commit f18e939

Please sign in to comment.