diff --git a/src/app/components/menu/menu.ts b/src/app/components/menu/menu.ts index 7b8baf5ad9d..7ed6962ec4d 100755 --- a/src/app/components/menu/menu.ts +++ b/src/app/components/menu/menu.ts @@ -168,7 +168,7 @@ export class MenuItemContent { pTooltip [tooltipOptions]="submenu.tooltipOptions" role="none" - [attr.id]="menuitemId(id, i)" + [attr.id]="menuitemId(item, id, i)" > {{ submenu.label }} @@ -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)" @@ -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)" > @@ -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)" @@ -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)" > @@ -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 : ''}`; }