diff --git a/libs/ui/src/lib/tags-selector/tags-selector.component.ts b/libs/ui/src/lib/tags-selector/tags-selector.component.ts index 7f1a8805e..42f52d4b3 100644 --- a/libs/ui/src/lib/tags-selector/tags-selector.component.ts +++ b/libs/ui/src/lib/tags-selector/tags-selector.component.ts @@ -77,7 +77,7 @@ export class GfTagsSelectorComponent this.tagInputControl.valueChanges .pipe(takeUntil(this.unsubscribeSubject)) .subscribe((value) => { - this.filteredOptions.next(this.filterTags(value)); + this.filteredOptions.next(this.filterTags(value ?? '')); }); addIcons({ addCircleOutline, closeOutline }); @@ -100,21 +100,24 @@ export class GfTagsSelectorComponent if (!tag && this.hasPermissionToCreateTag) { tag = { - id: undefined, + id: '', name: event.option.value as string, userId: null }; } - this.tagsSelected.update((tags) => { - return [...(tags ?? []), tag]; - }); + if (tag) { + this.tagsSelected.update((tags) => { + return [...(tags ?? []), tag]; + }); + + const newTags = this.tagsSelected(); + this.onChange(newTags); + this.onTouched(); + } - const newTags = this.tagsSelected(); - this.onChange(newTags); - this.onTouched(); this.tagInput.nativeElement.value = ''; - this.tagInputControl.setValue(undefined); + this.tagInputControl.setValue(null); } public onRemoveTag(tag: Tag) {