From b71bc216b835400c2d93f97a835e8cceaa5e7677 Mon Sep 17 00:00:00 2001 From: Roma Date: Thu, 11 Sep 2025 12:37:46 +0300 Subject: [PATCH] fix(tags-input): Fix strange behaviour when removing first tag --- .../components/tags-input/tags-input.component.html | 2 +- .../components/tags-input/tags-input.component.ts | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/app/shared/components/tags-input/tags-input.component.html b/src/app/shared/components/tags-input/tags-input.component.html index 02f8c1488..8eab8fb4e 100644 --- a/src/app/shared/components/tags-input/tags-input.component.html +++ b/src/app/shared/components/tags-input/tags-input.component.html @@ -8,7 +8,7 @@ (click)="!readonly() && onContainerClick()" (keydown)="!readonly() && onContainerKeydown($event)" > - @for (tag of localTags(); track $index) { + @for (tag of localTags(); track tag) { } diff --git a/src/app/shared/components/tags-input/tags-input.component.ts b/src/app/shared/components/tags-input/tags-input.component.ts index 3c8ba3678..b7f8c5d6d 100644 --- a/src/app/shared/components/tags-input/tags-input.component.ts +++ b/src/app/shared/components/tags-input/tags-input.component.ts @@ -32,17 +32,12 @@ export class TagsInputComponent { inputElement = viewChild>('tagInput'); localTags = signal([]); - private isLocalUpdate = false; constructor() { effect(() => { const incoming = this.tags(); - if (!this.isLocalUpdate) { - this.localTags.set([...incoming]); - } - - this.isLocalUpdate = false; + this.localTags.set([...incoming]); }); } @@ -92,8 +87,6 @@ export class TagsInputComponent { const updatedTags = [...currentTags, normalizedValue]; this.localTags.set(updatedTags); - this.isLocalUpdate = true; - this.tagsChanged.emit(updatedTags); } } @@ -105,8 +98,6 @@ export class TagsInputComponent { const updatedTags = currentTags.filter((_, i) => i !== index); this.localTags.set(updatedTags); - this.isLocalUpdate = true; - this.tagsChanged.emit(updatedTags); } }