Skip to content

Commit

Permalink
Resolves
Browse files Browse the repository at this point in the history
Gbuomprisco#959 - After chip completion, new chip contains previous chip's values
Gbuomprisco#945 - Adding tags very quickly causes error expressionChangedAfterItHasBeenCheckedError
Gbuomprisco#953 - (PERHAPS) Validating using formControlName does not work
  • Loading branch information
Doug Sellner committed Aug 17, 2020
1 parent d9840b9 commit b9967df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions modules/components/tag-input-form/tag-input-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -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 {
Expand All @@ -217,5 +220,6 @@ export class TagInputForm implements OnInit, OnChanges {
public submit($event: any): void {
$event.preventDefault();
this.onSubmit.emit($event);
this.form.reset();
}
}
2 changes: 1 addition & 1 deletion modules/components/tag-input/tag-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down

0 comments on commit b9967df

Please sign in to comment.