Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v18' into v18
Browse files Browse the repository at this point in the history
  • Loading branch information
cetincakiroglu committed Oct 16, 2024
2 parents d0a9c02 + 840a15e commit 62d6ff1
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/app/components/panelmenu/panelmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ export class PanelMenuList implements OnChanges {

@Input() items: any[];

@Input() itemTemplate: HTMLElement | undefined;
@Input() itemTemplate: TemplateRef<any> | undefined;

@Input({ transform: booleanAttribute }) parentExpanded: boolean | undefined;

Expand Down Expand Up @@ -571,13 +571,25 @@ export class PanelMenuList implements OnChanges {

onItemToggle(event) {
const { processedItem, expanded } = event;
processedItem.expanded = !processedItem.expanded;

const activeItemPath = this.activeItemPath().filter((p) => p.parentKey !== processedItem.parentKey);
expanded && activeItemPath.push(processedItem);
// Update the original item object's 'expanded' property
if (processedItem.item) {
processedItem.item.expanded = !processedItem.item.expanded;
}

// Recreate processedItems with updated 'expanded' states
this.processedItems.set(
this.createProcessedItems(this.items || [], 0, {}, '')
);

// Update activeItemPath
const activeItemPath = this.activeItemPath().filter((p) => p.parentKey !== processedItem.parentKey);
if (expanded) {
activeItemPath.push(processedItem);
}
this.activeItemPath.set(activeItemPath);
this.processedItems.update((value) => value.map((i) => (i === processedItem ? processedItem : i)));

// Update focusedItem
this.focusedItem.set(processedItem);
}

Expand Down Expand Up @@ -916,7 +928,7 @@ export class PanelMenuList implements OnChanges {
[ngClass]="{ 'p-panelmenu-expanded': isItemActive(item) }"
>
<div class="p-panelmenu-content" [attr.data-pc-section]="'menucontent'">
<p-panelmenu-list
<p-panelMenuList
[panelId]="getPanelId(i, item)"
[items]="getItemProp(item, 'items')"
[itemTemplate]="itemTemplate"
Expand All @@ -926,7 +938,7 @@ export class PanelMenuList implements OnChanges {
[tabindex]="tabindex"
[parentExpanded]="isItemActive(item)"
(headerFocus)="updateFocusedHeader($event)"
></p-panelmenu-list>
></p-panelMenuList>
</div>
</div>
</div>
Expand Down

0 comments on commit 62d6ff1

Please sign in to comment.