From cd91c76dc5e71ed778d8dbc8faaf4f190b21f10d Mon Sep 17 00:00:00 2001 From: Janne Julkunen Date: Sun, 6 Jan 2019 23:02:34 +0200 Subject: [PATCH] Send input change event also for invalid values, fixes #155 --- src/lib/color-picker.component.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/lib/color-picker.component.ts b/src/lib/color-picker.component.ts index 27f099b..3a2ec37 100644 --- a/src/lib/color-picker.component.ts +++ b/src/lib/color-picker.component.ts @@ -456,7 +456,9 @@ export class ColorPickerComponent implements OnInit, OnDestroy, AfterViewInit { validHex = /^#([a-f0-9]{3}|[a-f0-9]{6}|[a-f0-9]{8})$/gi; } - if (validHex.test(value)) { + const valid = validHex.test(value); + + if (valid) { if (value.length < 5) { value = '#' + value.substring(1) .split('') @@ -469,13 +471,14 @@ export class ColorPickerComponent implements OnInit, OnDestroy, AfterViewInit { } this.setColorFromString(value, true, false); - - this.directiveInstance.inputChanged({ - input: 'hex', - value: value, - color: this.outputColor - }); } + + this.directiveInstance.inputChanged({ + input: 'hex', + value: value, + valid: valid, + color: this.outputColor + }); } }