From d6de8f6fdbdef2b54951aa27191bdb281d318bcc Mon Sep 17 00:00:00 2001 From: Julian Dierkes Date: Fri, 15 Mar 2024 10:02:10 +0100 Subject: [PATCH] fixes 15058 - keyboard navigation for tieredmenu with hidden elements --- src/app/components/tieredmenu/tieredmenu.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/components/tieredmenu/tieredmenu.ts b/src/app/components/tieredmenu/tieredmenu.ts index b72a5e105a0..2138e577a05 100755 --- a/src/app/components/tieredmenu/tieredmenu.ts +++ b/src/app/components/tieredmenu/tieredmenu.ts @@ -288,7 +288,11 @@ export class TieredMenuSub { } getAriaPosInset(index: number) { - return index - this.items.slice(0, index).filter((processedItem) => this.isItemVisible(processedItem) && this.getItemProp(processedItem, 'separator')).length + 1; + return index - this.items.slice(0, index).filter((processedItem) => { + const isItemVisible = this.isItemVisible(processedItem); + const isVisibleSeparator = isItemVisible && this.getItemProp(processedItem, 'separator'); + return !isItemVisible || isVisibleSeparator; + }).length + 1; } isItemVisible(processedItem: any): boolean { @@ -625,13 +629,17 @@ export class TieredMenu implements OnInit, AfterContentInit, OnDestroy { } isValidItem(processedItem: any): boolean { - return !!processedItem && !this.isItemDisabled(processedItem.item) && !this.isItemSeparator(processedItem.item); + return !!processedItem && !this.isItemDisabled(processedItem.item) && !this.isItemSeparator(processedItem.item) && this.isItemVisible(processedItem.item); } isItemDisabled(item: any): boolean { return this.getItemProp(item, 'disabled'); } + isItemVisible(item: any): boolean { + return this.getItemProp(item, 'visible') !== false; + } + isItemSeparator(item: any): boolean { return this.getItemProp(item, 'separator'); }