Skip to content

Commit

Permalink
Fixed #1621 - [Feature Request] Disable +- Button on InputNumber when…
Browse files Browse the repository at this point in the history
… value reach min, max
  • Loading branch information
tugcekucukoglu committed Nov 4, 2021
1 parent 4547fe5 commit 0d049b4
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/components/inputnumber/InputNumber.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,14 @@ export default {
timer: null,
data() {
return {
d_modelValue: this.modelValue,
focused: false
}
},
watch: {
modelValue(newValue) {
this.d_modelValue = newValue;
},
locale(newValue, oldValue) {
this.updateConstructParser(newValue, oldValue);
},
Expand Down Expand Up @@ -891,6 +895,7 @@ export default {
return 0;
},
updateModel(event, value) {
this.d_modelValue = value;
this.$emit('update:modelValue', value);
},
onInputFocus() {
Expand All @@ -909,7 +914,13 @@ export default {
if (this.timer) {
clearInterval(this.timer);
}
}
},
maxBoundry() {
return this.d_modelValue >= this.max;
},
minBoundry() {
return this.d_modelValue <= this.min;
},
},
computed: {
containerClass() {
Expand All @@ -921,11 +932,16 @@ export default {
'p-inputnumber-buttons-vertical': this.showButtons && this.buttonLayout === 'vertical'
}];
},
upButtonClass() {
return ['p-inputnumber-button p-inputnumber-button-up', this.incrementButtonClass];
return ['p-inputnumber-button p-inputnumber-button-up', this.incrementButtonClass, {
'p-disabled': this.showButtons && this.max !== null && this.maxBoundry()
}];
},
downButtonClass() {
return ['p-inputnumber-button p-inputnumber-button-down', this.decrementButtonClass];
return ['p-inputnumber-button p-inputnumber-button-down', this.decrementButtonClass, {
'p-disabled': this.showButtons && this.min !== null && this.minBoundry()
}];
},
filled() {
return (this.modelValue != null && this.modelValue.toString().length > 0)
Expand Down

0 comments on commit 0d049b4

Please sign in to comment.