From 0d049b4ca082cfd9a9c2a1be25ca237b302f9b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Thu, 4 Nov 2021 10:33:11 +0300 Subject: [PATCH] Fixed #1621 - [Feature Request] Disable +- Button on InputNumber when value reach min, max --- src/components/inputnumber/InputNumber.vue | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/components/inputnumber/InputNumber.vue b/src/components/inputnumber/InputNumber.vue index 849ef613e..ad25accbc 100755 --- a/src/components/inputnumber/InputNumber.vue +++ b/src/components/inputnumber/InputNumber.vue @@ -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); }, @@ -891,6 +895,7 @@ export default { return 0; }, updateModel(event, value) { + this.d_modelValue = value; this.$emit('update:modelValue', value); }, onInputFocus() { @@ -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() { @@ -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)