diff --git a/modules/components/tag-input-form/tag-input-form.component.ts b/modules/components/tag-input-form/tag-input-form.component.ts index f08f42a3..40613e51 100644 --- a/modules/components/tag-input-form/tag-input-form.component.ts +++ b/modules/components/tag-input-form/tag-input-form.component.ts @@ -94,14 +94,18 @@ export class TagInputForm implements OnInit, OnChanges { return this.item.value; } + private _inputText: string; + /** * @name inputText * @param text {string} */ public set inputText(text: string) { - this.item.setValue(text); - - this.inputTextChange.emit(text); + if ( this._inputText != text ) { + this._inputText = text; + this.item.setValue(text); + this.inputTextChange.emit(text); + } } private readonly item: FormControl = new FormControl({ value: '', disabled: this.disabled }); @@ -194,7 +198,6 @@ export class TagInputForm implements OnInit, OnChanges { * @param $event */ public onKeyDown($event) { - this.inputText = this.value.value; if ($event.key === 'Enter') { this.submit($event); } else { @@ -217,5 +220,6 @@ export class TagInputForm implements OnInit, OnChanges { public submit($event: any): void { $event.preventDefault(); this.onSubmit.emit($event); + this.form.reset(); } } diff --git a/modules/components/tag-input/tag-input.ts b/modules/components/tag-input/tag-input.ts index b848dc34..e948f00e 100644 --- a/modules/components/tag-input/tag-input.ts +++ b/modules/components/tag-input/tag-input.ts @@ -653,7 +653,7 @@ export class TagInputComponent extends TagInputAccessor implements OnInit, After * @name hasErrors */ public hasErrors(): boolean { - return !!this.inputForm && this.inputForm.hasErrors(); + return !!this.inputForm && !!this.inputForm.hasErrors(); } /**