Skip to content

Commit

Permalink
fix: #16684, MultiSelect: Unable to select remove icon of chips throu…
Browse files Browse the repository at this point in the history
…gh keyboard
  • Loading branch information
ANTONA09 committed Nov 3, 2024
1 parent 3f1e943 commit 79dfa42
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/app/components/multiselect/multiselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,20 @@ export class MultiSelectItem {
[ngClass]="{ 'p-disabled': isOptionDisabled(item) }"
[styleClass]="'p-multiselect-token-icon'"
(click)="removeOption(item, event)"
(keydown)="onremoveTokenIconKeyDown($event, item)"
[attr.tabindex]="0"
[attr.data-pc-section]="'clearicon'"
[attr.aria-hidden]="true"
/>
<span *ngIf="removeTokenIconTemplate" class="p-multiselect-token-icon" (click)="removeOption(item, event)" [attr.data-pc-section]="'clearicon'" [attr.aria-hidden]="true">
<span
*ngIf="removeTokenIconTemplate"
class="p-multiselect-token-icon"
(click)="removeOption(item, event)"
(keydown)="onremoveTokenIconKeyDown($event, item)"
[attr.tabindex]="0"
[attr.data-pc-section]="'clearicon'"
[attr.aria-hidden]="true"
>
<ng-container *ngTemplateOutlet="removeTokenIconTemplate"></ng-container>
</span>
</ng-container>
Expand Down Expand Up @@ -1916,6 +1926,26 @@ export class MultiSelect implements OnInit, AfterViewInit, AfterContentInit, Aft
}
}

onremoveTokenIconKeyDown(event, item) {
if (this.disabled) {
event.preventDefault();

return;
}

switch (event.code) {
case 'Space':
case 'Enter':
case 'NumpadEnter':
this.removeOption(item, event);
break;
default:
break;
}
event.preventDefault();
event.stopPropagation();
}

onFilterBlur(event) {
this.focusedOptionIndex.set(-1);
}
Expand Down

0 comments on commit 79dfa42

Please sign in to comment.