Skip to content

Commit

Permalink
Send input change event also for invalid values, fixes #155
Browse files Browse the repository at this point in the history
  • Loading branch information
sconix committed Jan 6, 2019
1 parent e3058b8 commit cd91c76
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/lib/color-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('')
Expand All @@ -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
});
}
}

Expand Down

0 comments on commit cd91c76

Please sign in to comment.