Skip to content

Commit

Permalink
Merge pull request #15060 from Nas3nmann/fix-15058
Browse files Browse the repository at this point in the history
fixes 15058 - keyboard navigation for tieredmenu with hidden elements
  • Loading branch information
cetincakiroglu authored Mar 20, 2024
2 parents 6c1f8b0 + d6de8f6 commit 11766c3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/app/components/tieredmenu/tieredmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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');
}
Expand Down

0 comments on commit 11766c3

Please sign in to comment.