Skip to content

Commit

Permalink
fixes 15058 - keyboard navigation for tieredmenu with hidden elements
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-exb committed Mar 18, 2024
1 parent 2deca2d commit d6de8f6
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 d6de8f6

Please sign in to comment.