Open DavidDecraene opened 7 years ago
Same issue here. The changeInput method is causing this, it is at line 104 in color-picker.directive.ts I wanted to add a guard for the method but I can't make it compile with my changes.
changeInput(value: string) {
if (this.dialog) this.dialog.setColorFromString(value, true);
}
<input class="form-control" [cpPosition]="'bottom'" [(colorPicker)]="value" [value]="value"/>
Given the above and a default value in the text field, If I, before opening the color picker once, select all text in the input field with the mouse and hit backspace (deleting it), I get an error:
error_handler.js:56 TypeError: Cannot read property 'setColorFromString' of undefined at ColorPickerDirective.changeInput (color-picker.directive.js:91) at Wrapper_ColorPickerDirective.handleEvent (/ColorPickerModule/ColorPickerDirective/wrapper.ngfactory.js:246) at CompiledTemplate.proxyViewClass.View_ColorFieldComponent0.handleEvent_8 (/FormModule/ColorFieldComponent/component.ngfactory.js:144) at CompiledTemplate.proxyViewClass. (view.js:664)
at HTMLInputElement. (dom_renderer.js:486)
at ZoneDelegate.webpackJsonp.1509.ZoneDelegate.invokeTask (zone.js:275)
at Object.onInvokeTask (ng_zone.js:260)
at ZoneDelegate.webpackJsonp.1509.ZoneDelegate.invokeTask (zone.js:274)
at Zone.webpackJsonp.1509.Zone.runTask (zone.js:151)
at HTMLInputElement.ZoneTask.invoke (zone.js:345)
If someone first clicked in the field, and then tries the same, you don't get the error. If you delete the characters one by one (same deal, initalizes a color picker view) you dont get the error. The error only occurs when deleting all text of the text box without ever having seen the color picker dialog.