Fixed #337 - InputNumber prevents min key number
parent
6b921999f0
commit
d6d2b92dcb
|
@ -207,18 +207,10 @@ export default {
|
||||||
|
|
||||||
this.spin(event, dir);
|
this.spin(event, dir);
|
||||||
},
|
},
|
||||||
spin(event, dir) {
|
spin(event, dir, value) {
|
||||||
let step = this.step * dir;
|
let step = this.step * dir;
|
||||||
let currentValue = this.value || 0;
|
let currentValue = this.parseValue(this.$refs.input.$el.value) || 0;
|
||||||
let newValue = currentValue + step;
|
let newValue = this.validateValue(currentValue + step);
|
||||||
|
|
||||||
if (this.min !== null && newValue < this.min) {
|
|
||||||
newValue = this.min;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.max !== null && newValue > this.max) {
|
|
||||||
newValue = this.max;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateInput(newValue, 'spin');
|
this.updateInput(newValue, 'spin');
|
||||||
this.updateModel(event, newValue);
|
this.updateModel(event, newValue);
|
||||||
|
@ -492,16 +484,19 @@ export default {
|
||||||
updateValue(event, valueStr, operation) {
|
updateValue(event, valueStr, operation) {
|
||||||
if (valueStr != null) {
|
if (valueStr != null) {
|
||||||
let newValue = this.parseValue(valueStr);
|
let newValue = this.parseValue(valueStr);
|
||||||
let valid = this.isWithinRange(newValue);
|
|
||||||
|
|
||||||
if (valid) {
|
|
||||||
this.updateInput(newValue, operation);
|
this.updateInput(newValue, operation);
|
||||||
this.updateModel(event, newValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isWithinRange(value) {
|
validateValue(value) {
|
||||||
return value == null || ((this.min == null || value > this.min) && (this.max == null || value < this.max));
|
if (this.min != null && value < this.min) {
|
||||||
|
return this.min;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.max != null && value > this.max) {
|
||||||
|
return this.max;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
},
|
},
|
||||||
updateInput(value, operation) {
|
updateInput(value, operation) {
|
||||||
let currentLength = this.$refs.input.$el.value.length;
|
let currentLength = this.$refs.input.$el.value.length;
|
||||||
|
@ -545,6 +540,12 @@ export default {
|
||||||
},
|
},
|
||||||
onInputBlur(event) {
|
onInputBlur(event) {
|
||||||
this.focused = false;
|
this.focused = false;
|
||||||
|
|
||||||
|
let newValue = this.validateValue(this.parseValue(this.$refs.input.$el.value));
|
||||||
|
this.$refs.input.$el.value = this.formatValue(newValue);
|
||||||
|
this.$refs.input.$el.setAttribute('aria-valuenow', newValue);
|
||||||
|
this.updateModel(event, newValue);
|
||||||
|
|
||||||
this.$emit('blur', event);
|
this.$emit('blur', event);
|
||||||
},
|
},
|
||||||
clearTimer() {
|
clearTimer() {
|
||||||
|
|
Loading…
Reference in New Issue