I'm trying to implement a MatTable
with keyboard interaction, in order to select the rows inside the table.
For the keyboard interaction, I've used FocusKeyManager
from Cdk
's- a11y
module. Also, the keydown
event is attached to the host (mat-table
).
this.keyManager = new FocusKeyManager<MatRowFocusableDirective>(
this.rows
).withHomeAndEnd();
@HostListener("keydown", ["$event"])
public onKeydownHandler(event: KeyboardEvent): void {
this.keyManager.onKeydown(event);
}
At this point, everything works fine.
But I wanted to extend the keyboard interaction, similar to the Gmail web app:
on any keypress (up/down arrow) inside the document, I want to start the navigation inside the table:
@HostListener("document:keydown", ["$event"]) public onKeydownHandler(event: KeyboardEvent): void { this.keyManager.onKeydown(event); }
This works, but, in the app, I also use other Angular Material components that are build upon CDK Overlays, like Dialogs, Selects, Bottomsheets, etc.
The issue is that when one of these components is opened, the keyboard interaction within the table is still available.
How can I disable the keyboard interaction within the table when any of the CDK Overlay components is opened?