Skip to content

Commit

Permalink
Fixed primefaces#13827 - Update conditionals for disabled menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetcetin01140 committed Oct 9, 2023
1 parent 3ba085e commit 5a2c26f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/app/components/panelmenu/panelmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import { ObjectUtils, UniqueComponentId } from 'primeng/utils';
<li *ngIf="processedItem.separator" class="p-menuitem-separator" role="separator"></li>
<li
*ngIf="!processedItem.separator && isItemVisible(processedItem)"
class="p-menuitem"
[ngClass]="getItemClass(processedItem)"
role="treeitem"
[id]="getItemId(processedItem)"
[attr.aria-label]="getItemProp(processedItem, 'label')"
Expand All @@ -61,9 +61,10 @@ import { ObjectUtils, UniqueComponentId } from 'primeng/utils';
[attr.aria-posinset]="getAriaPosInset(index)"
[class]="getItemProp(processedItem, 'styleClass')"
[class.p-hidden]="processedItem.visible === false"
[class.p-focus]="isItemFocused(processedItem)"
[class.p-focus]="isItemFocused(processedItem) && !isItemDisabled(processedItem)"
[ngStyle]="getItemProp(processedItem, 'style')"
[pTooltip]="getItemProp(processedItem, 'tooltip')"
[attr.data-p-disabled]="isItemDisabled(processedItem)"
[tooltipOptions]="getItemProp(processedItem, 'tooltipOptions')"
>
<div class="p-menuitem-content" (click)="onItemClick($event, processedItem)">
Expand Down Expand Up @@ -200,6 +201,13 @@ export class PanelMenuSub {
return this.getItemId(processedItem);
}

getItemClass(processedItem) {
return {
'p-menuitem': true,
'p-disabled': this.isItemDisabled(processedItem)
}
}

getItemProp(processedItem, name?, params?) {
return processedItem && processedItem.item ? ObjectUtils.getItemValue(processedItem.item[name], params) : undefined;
}
Expand Down Expand Up @@ -245,8 +253,10 @@ export class PanelMenuSub {
}

onItemClick(event, processedItem) {
this.getItemProp(processedItem, 'command', { originalEvent: event, item: processedItem.item });
this.itemToggle.emit({ processedItem, expanded: !this.isItemActive(processedItem) });
if(!this.isItemDisabled(processedItem)) {
this.getItemProp(processedItem, 'command', { originalEvent: event, item: processedItem.item });
this.itemToggle.emit({ processedItem, expanded: !this.isItemActive(processedItem) });
}
}

onItemToggle(event) {
Expand Down Expand Up @@ -1060,4 +1070,4 @@ export class PanelMenu implements AfterContentInit {
exports: [PanelMenu, RouterModule, TooltipModule, SharedModule],
declarations: [PanelMenu, PanelMenuSub, PanelMenuList]
})
export class PanelMenuModule {}
export class PanelMenuModule {}

0 comments on commit 5a2c26f

Please sign in to comment.