Skip to content

Commit 2dedc73

Browse files
authored
fix(tags-input): Fix strange behaviour when removing first tag (#361)
1 parent 978ce90 commit 2dedc73

2 files changed

Lines changed: 2 additions & 11 deletions

File tree

‎src/app/shared/components/tags-input/tags-input.component.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
(click)="!readonly() && onContainerClick()"
99
(keydown)="!readonly() && onContainerKeydown($event)"
1010
>
11-
@for (tag of localTags(); track $index) {
11+
@for (tag of localTags(); track tag) {
1212
<p-chip [label]="tag" [removable]="!readonly()" (onRemove)="removeTag($index)" class="p-chip-inline" />
1313
}
1414

‎src/app/shared/components/tags-input/tags-input.component.ts‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,12 @@ export class TagsInputComponent {
3232
inputElement = viewChild<ElementRef<HTMLInputElement>>('tagInput');
3333

3434
localTags = signal<string[]>([]);
35-
private isLocalUpdate = false;
3635

3736
constructor() {
3837
effect(() => {
3938
const incoming = this.tags();
4039

41-
if (!this.isLocalUpdate) {
42-
this.localTags.set([...incoming]);
43-
}
44-
45-
this.isLocalUpdate = false;
40+
this.localTags.set([...incoming]);
4641
});
4742
}
4843

@@ -92,8 +87,6 @@ export class TagsInputComponent {
9287
const updatedTags = [...currentTags, normalizedValue];
9388

9489
this.localTags.set(updatedTags);
95-
this.isLocalUpdate = true;
96-
9790
this.tagsChanged.emit(updatedTags);
9891
}
9992
}
@@ -105,8 +98,6 @@ export class TagsInputComponent {
10598
const updatedTags = currentTags.filter((_, i) => i !== index);
10699

107100
this.localTags.set(updatedTags);
108-
this.isLocalUpdate = true;
109-
110101
this.tagsChanged.emit(updatedTags);
111102
}
112103
}

0 commit comments

Comments
 (0)