Skip to content

Commit a1d6275

Browse files
committed
fix: reach min and max value issues
1 parent 938130e commit a1d6275

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class InputSpinner extends Component {
9797
* @private
9898
*/
9999
_setStateMin(callback = null) {
100-
return this.setState({value: this.state.max}, callback);
100+
return this.setState({value: this.state.min}, callback);
101101
}
102102

103103
/**
@@ -338,8 +338,9 @@ class InputSpinner extends Component {
338338
*/
339339
async increase() {
340340
if (this._isDisabledButtonRight()) return;
341-
let num = this.parseNum(this.state.value) + this.parseNum(this.state.step);
342-
if (this.maxReached(num)) {
341+
let currentValue = this.parseNum(this.state.value);
342+
let num = currentValue + this.parseNum(this.state.step);
343+
if (this.maxReached(currentValue)) {
343344
return;
344345
}
345346
if (this.props.onIncrease) {
@@ -366,8 +367,9 @@ class InputSpinner extends Component {
366367
*/
367368
async decrease() {
368369
if (this._isDisabledButtonLeft()) return;
369-
let num = this.parseNum(this.state.value) - this.parseNum(this.state.step);
370-
if (this.minReached(num)) {
370+
let currentValue = this.parseNum(this.state.value);
371+
let num = currentValue - this.parseNum(this.state.step);
372+
if (this.minReached(currentValue)) {
371373
return;
372374
}
373375
if (this.props.onDecrease) {

0 commit comments

Comments
 (0)