From 13988e35f1971759809e1223c571121ac33474a3 Mon Sep 17 00:00:00 2001 From: betavs Date: Fri, 19 Jan 2024 12:15:10 +0800 Subject: [PATCH 1/2] fix(color-picker): change event only shows old color value --- components/lib/colorpicker/ColorPicker.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/lib/colorpicker/ColorPicker.vue b/components/lib/colorpicker/ColorPicker.vue index 5fffba530..76f30f4c8 100755 --- a/components/lib/colorpicker/ColorPicker.vue +++ b/components/lib/colorpicker/ColorPicker.vue @@ -97,7 +97,10 @@ export default { this.updateColorHandle(); this.updateInput(); this.updateModel(); - this.$emit('change', { event: event, value: this.modelValue }); + + this.$nextTick(() => { + this.$emit('change', { event: event, value: this.modelValue }); + }); }, pickHue(event) { let top = this.hueView.getBoundingClientRect().top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0); @@ -113,7 +116,10 @@ export default { this.updateHue(); this.updateModel(); this.updateInput(); - this.$emit('change', { event: event, value: this.modelValue }); + + this.$nextTick(() => { + this.$emit('change', { event: event, value: this.modelValue }); + }); }, updateModel() { switch (this.format) { From b6ba282917f82da5021ed46e5bec8dbdb5847391 Mon Sep 17 00:00:00 2001 From: betavs Date: Thu, 25 Jan 2024 10:12:00 +0800 Subject: [PATCH 2/2] perf(color-picker): change event only shows old color value --- components/lib/colorpicker/ColorPicker.vue | 25 ++++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/components/lib/colorpicker/ColorPicker.vue b/components/lib/colorpicker/ColorPicker.vue index 76f30f4c8..42d6bc420 100755 --- a/components/lib/colorpicker/ColorPicker.vue +++ b/components/lib/colorpicker/ColorPicker.vue @@ -96,11 +96,7 @@ export default { this.selfUpdate = true; this.updateColorHandle(); this.updateInput(); - this.updateModel(); - - this.$nextTick(() => { - this.$emit('change', { event: event, value: this.modelValue }); - }); + this.updateModel(event); }, pickHue(event) { let top = this.hueView.getBoundingClientRect().top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0); @@ -114,31 +110,32 @@ export default { this.selfUpdate = true; this.updateColorSelector(); this.updateHue(); - this.updateModel(); + this.updateModel(event); this.updateInput(); - - this.$nextTick(() => { - this.$emit('change', { event: event, value: this.modelValue }); - }); }, - updateModel() { + updateModel(event) { + let value = this.modelValue; + switch (this.format) { case 'hex': - this.$emit('update:modelValue', this.HSBtoHEX(this.hsbValue)); + value = this.HSBtoHEX(this.hsbValue); break; case 'rgb': - this.$emit('update:modelValue', this.HSBtoRGB(this.hsbValue)); + value = this.HSBtoRGB(this.hsbValue); break; case 'hsb': - this.$emit('update:modelValue', this.hsbValue); + value = this.hsbValue; break; default: //NoOp break; } + + this.$emit('update:modelValue', value); + this.$emit('change', { event, value }); }, updateColorSelector() { if (this.colorSelector) {