<ng-template ng-label-tmp let-document="item">
<div class="d-flex align-items-center">
@if (!disabled) {
- <button class="btn p-0 lh-1" (click)="unselect(document)" type="button" title="Remove link" i18n-title><i-bs name="x"></i-bs></button>
+ <button class="btn p-0 lh-1" (click)="unselect(document)" (mousedown)="$event.stopImmediatePropagation()" type="button" title="Remove link" i18n-title><i-bs name="x"></i-bs></button>
}
@if (document.title) {
<a routerLink="/documents/{{document.id}}" class="badge bg-light text-primary" (mousedown)="$event.stopImmediatePropagation();" title="Open link" i18n-title>
<i-bs width="0.9em" height="0.9em" name="file-text"></i-bs> <span>{{document.title}}</span>
</a>
} @else {
- <span class="badge bg-light text-muted" (click)="unselect(document)" type="button" title="Remove link" i18n-title>
+ <span class="badge bg-light text-muted" (click)="unselect(document)" (mousedown)="$event.stopImmediatePropagation()" type="button" title="Remove link" i18n-title>
<i-bs width="0.9em" height="0.9em" name="exclamation-triangle-fill"></i-bs> <span i18n>Not found</span>
</span>
}
(change)="onChange(value)">
<ng-template ng-label-tmp let-item="item">
- <button class="tag-wrap btn p-0 d-flex align-items-center" (click)="removeTag($event, item.id)" title="Remove tag" i18n-title>
+ <button class="tag-wrap btn p-0 d-flex align-items-center" (click)="removeTag(item.id)" (mousedown)="$event.stopImmediatePropagation()" type="button" title="Remove tag" i18n-title>
<i-bs name="x" style="margin-inline-end: 1px;"></i-bs>
@if (item.id && tags) {
<pngx-tag style="background-color: none;" [tag]="getTag(item.id)"></pngx-tag>
it('support remove tags', () => {
component.tags = tags
component.value = [1, 2]
- component.removeTag(new PointerEvent('point'), 2)
+ component.removeTag(2)
expect(component.value).toEqual([1])
component.disabled = true
- component.removeTag(new PointerEvent('point'), 1)
+ component.removeTag(1)
expect(component.value).toEqual([1])
})
}
}
- removeTag(event: PointerEvent, id: number) {
+ removeTag(tagID: number) {
if (this.disabled) return
- // prevent opening dropdown
- event.stopImmediatePropagation()
-
- let index = this.value.indexOf(id)
+ let index = this.value.indexOf(tagID)
if (index > -1) {
let oldValue = this.value
oldValue.splice(index, 1)