mirror of
https://github.com/bitwarden/browser
synced 2026-02-04 02:33:33 +00:00
reduce amount of menuitem type casting
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { FocusKeyManager, CdkTrapFocus, FocusableOption } from "@angular/cdk/a11y";
|
||||
import { FocusKeyManager, CdkTrapFocus } from "@angular/cdk/a11y";
|
||||
import {
|
||||
Component,
|
||||
Output,
|
||||
@@ -34,11 +34,12 @@ export class MenuComponent implements AfterContentInit {
|
||||
|
||||
ngAfterContentInit() {
|
||||
if (this.ariaRole() === "menu") {
|
||||
this.keyManager = new FocusKeyManager(
|
||||
this.menuItems() as unknown as (FocusableOption & MenuItemComponent)[],
|
||||
)
|
||||
// Type cast is necessary because MenuItemComponent.disabled is a ModelSignal<boolean>
|
||||
// to satisfy ButtonLikeAbstraction, but FocusKeyManager expects disabled?: boolean.
|
||||
// The skipPredicate correctly calls disabled() to read the signal value.
|
||||
this.keyManager = new FocusKeyManager<MenuItemComponent>(this.menuItems() as any)
|
||||
.withWrap()
|
||||
.skipPredicate((item) => !!(item as MenuItemComponent).disabled());
|
||||
.skipPredicate((item: MenuItemComponent) => !!item.disabled());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user