I want to make some actions When navigating between items using keyboard arrows.
Is there any event should i implemented? The selectionChange is fired by clicking ENTER but i want to activate the function while navigating by arrows.
<mat-selection-list #list (selectionChange)="selectionChange($event, list.selectedOptions)">
<mat-list-option (mouseenter)="showEditIcon(true, i)" (mouseleave)="showEditIcon(false, i)"
*ngFor="let lotItem of lotList; let i = index;"
(click)="showLotDetails(lotItem, i)"
[value]='lotItem'>
You can use the keydown keyboard event on your mat-selection-list in order to call your selectionChange() method. You'll need to add both (keydown.arrowup) and (keydown.arrowdown) event handlers.
<mat-selection-list #list
(selectionChange)="selectionChange($event, list.selectedOptions)"
(keydown.arrowup)="selectionChange($event)"
(keydown.arrowdown)="selectionChange($event)">
<mat-list-option (mouseenter)="showEditIcon(true, i)" (mouseleave)="showEditIcon(false, i)"
*ngFor="let lotItem of lotList; let i = index;"
(click)="showLotDetails(lotItem, i)"
[value]='lotItem'>
Here is a StackBlitz Demo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With