Skip to content

Commit

Permalink
Fixed #14295
Browse files Browse the repository at this point in the history
  • Loading branch information
cetincakiroglu committed Dec 12, 2023
1 parent b49fedf commit 1fba2ff
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/app/components/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
ViewEncapsulation,
ViewRef,
computed,
effect,
forwardRef,
signal
} from '@angular/core';
Expand Down Expand Up @@ -117,8 +118,6 @@ export class MenuItemContent {

@Input() itemTemplate: HTMLElement | undefined;

@Input() id: string;

@Output() onMenuItemClick: EventEmitter<any> = new EventEmitter<any>();

menu: Menu;
Expand All @@ -128,7 +127,7 @@ export class MenuItemContent {
}

onItemClick(event, item) {
this.onMenuItemClick.emit({ originalEvent: event, item: { ...item, id: this.id } });
this.onMenuItemClick.emit({ originalEvent: event, item });
}
}
/**
Expand Down Expand Up @@ -194,7 +193,7 @@ export class MenuItemContent {
[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)"
(onMenuItemClick)="itemClick($event, menuitemId(item, id, i, j))"
pTooltip
[tooltipOptions]="item.tooltipOptions"
role="menuitem"
Expand All @@ -217,7 +216,7 @@ export class MenuItemContent {
[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)"
(onMenuItemClick)="itemClick($event, menuitemId(item, id, i))"
pTooltip
[tooltipOptions]="item.tooltipOptions"
role="menuitem"
Expand Down Expand Up @@ -653,7 +652,7 @@ export class Menu implements OnDestroy {
}
}

itemClick(event: any) {
itemClick(event: any, id: string) {
const { originalEvent, item } = event;

if (item.disabled) {
Expand All @@ -676,8 +675,8 @@ export class Menu implements OnDestroy {
this.hide();
}

if (!this.popup && this.focusedOptionIndex() !== item.id) {
this.focusedOptionIndex.set(item.id);
if (!this.popup && this.focusedOptionIndex() !== id) {
this.focusedOptionIndex.set(id);
}
}

Expand Down

0 comments on commit 1fba2ff

Please sign in to comment.