Skip to content

Commit

Permalink
Fixed #13705 - Update menuitemId method
Browse files Browse the repository at this point in the history
  • Loading branch information
cetincakiroglu committed Sep 19, 2023
1 parent 458014d commit 44a5075
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/app/components/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class MenuItemContent {
pTooltip
[tooltipOptions]="submenu.tooltipOptions"
role="none"
[attr.id]="menuitemId(id, i)"
[attr.id]="menuitemId(item, id, i)"
>
<span *ngIf="submenu.escape !== false; else htmlSubmenuLabel">{{ submenu.label }}</span>
<ng-template #htmlSubmenuLabel><span [innerHTML]="submenu.label | safeHtml"></span></ng-template>
Expand All @@ -179,7 +179,7 @@ export class MenuItemContent {
class="p-menuitem"
*ngIf="!item.separator"
[pMenuItemContent]="item"
[ngClass]="{ 'p-hidden': item.visible === false || submenu.visible === false, 'p-focus': focusedOptionId() && menuitemId(id, i, j) === focusedOptionId(), 'p-disabled': disabled(item.disabled) }"
[ngClass]="{ 'p-hidden': item.visible === false || submenu.visible === false, 'p-focus': focusedOptionId() && menuitemId(item, id, i, j) === focusedOptionId(), 'p-disabled': disabled(item.disabled) }"
[ngStyle]="item.style"
[class]="item.styleClass"
(onMenuItemClick)="itemClick($event)"
Expand All @@ -188,11 +188,11 @@ export class MenuItemContent {
role="menuitem"
[attr.data-pc-section]="'menuitem'"
[attr.aria-label]="label(item.label)"
[attr.data-p-focused]="isItemFocused(menuitemId(id, i, j))"
[attr.data-p-focused]="isItemFocused(menuitemId(item, id, i, j))"
[attr.data-p-disabled]="disabled(item.disabled)"
[attr.aria-disabled]="disabled(item.disabled)"
[attr.id]="menuitemId(id, i, j)"
[id]="menuitemId(id, i, j)"
[attr.id]="menuitemId(item, id, i, j)"
[id]="menuitemId(item, id, i, j)"
></li>
</ng-template>
</ng-template>
Expand All @@ -202,7 +202,7 @@ export class MenuItemContent {
class="p-menuitem"
*ngIf="!item.separator"
[pMenuItemContent]="item"
[ngClass]="{ 'p-hidden': item.visible === false, 'p-focus': focusedOptionId() && menuitemId(id, i) === focusedOptionId(), 'p-disabled': disabled(item.disabled) }"
[ngClass]="{ 'p-hidden': item.visible === false, 'p-focus': focusedOptionId() && menuitemId(item, id, i, j) === focusedOptionId(), 'p-disabled': disabled(item.disabled) }"
[ngStyle]="item.style"
[class]="item.styleClass"
(onMenuItemClick)="itemClick($event)"
Expand All @@ -211,11 +211,11 @@ export class MenuItemContent {
role="menuitem"
[attr.data-pc-section]="'menuitem'"
[attr.aria-label]="label(item.label)"
[attr.data-p-focused]="isItemFocused(menuitemId(id, i))"
[attr.data-p-focused]="isItemFocused(menuitemId(item, id, i))"
[attr.data-p-disabled]="disabled(item.disabled)"
[attr.aria-disabled]="disabled(item.disabled)"
[attr.id]="menuitemId(id, i)"
[id]="menuitemId(id, i)"
[attr.id]="menuitemId(item, id, i)"
[id]="menuitemId(item, id, i)"
></li>
</ng-template>
</ul>
Expand Down Expand Up @@ -466,7 +466,10 @@ export class Menu implements OnDestroy {
}

menuitemId(item: MenuItem, id: string, index?: string, childIndex?: string) {
// let itemId = item.id ?? id;
if(item && item.id && item.id !== undefined) {
return item.id;
} else {
}
return `${id}_${index}${typeof childIndex !== 'undefined' ? '_' + childIndex : ''}`;
}

Expand Down

1 comment on commit 44a5075

@vercel
Copy link

@vercel vercel bot commented on 44a5075 Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.