Skip to content

Commit 6e8ff1d

Browse files
Merge pull request #5776 from Countly/fix-color-picker-reset
Fix: prevent console errors when resetting color
2 parents 90d4dad + b85d8e0 commit 6e8ff1d

File tree

1 file changed

+8
-2
lines changed
  • frontend/express/public/javascripts/countly/vue/components

1 file changed

+8
-2
lines changed

frontend/express/public/javascripts/countly/vue/components/input.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@
2828
},
2929
localValue: {
3030
get: function() {
31-
return this.value.replace("#", "");
31+
var rawValue = this.value || this.resetValue;
32+
33+
return rawValue.replace("#", "");
3234
},
3335
set: function(value) {
3436
var colorValue = "#" + value.replace("#", "");
37+
3538
if (colorValue.match(HEX_COLOR_REGEX)) {
3639
this.setColor({hex: colorValue});
3740
}
@@ -43,10 +46,13 @@
4346
},
4447
methods: {
4548
setColor: function(color) {
46-
this.$emit("input", color.hex8);
49+
var finalColor = color.hex8 || color.hex;
50+
51+
this.$emit("input", finalColor);
4752
},
4853
reset: function() {
4954
this.setColor({hex: this.resetValue});
55+
this.close();
5056
},
5157
open: function() {
5258
this.isOpened = true;

0 commit comments

Comments
 (0)