From 2183301e19af35e77bcb4d47385ab9daa772c12b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9rez?= Date: Tue, 26 Sep 2023 12:31:47 +0200 Subject: [PATCH 1/4] Fixed tree onKeyDown with contextMenu --- src/app/components/tree/tree.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/tree/tree.ts b/src/app/components/tree/tree.ts index d16d5fcc3d9..b580b05510c 100755 --- a/src/app/components/tree/tree.ts +++ b/src/app/components/tree/tree.ts @@ -487,7 +487,7 @@ export class UITreeNode implements OnInit { onKeyDown(event: KeyboardEvent) { const nodeElement = (event.target).parentElement?.parentElement; - if (nodeElement?.nodeName !== 'P-TREENODE' || (this.tree.contextMenu && this.tree.contextMenu.containerViewChild.nativeElement.style.display === 'block')) { + if (nodeElement?.nodeName !== 'P-TREENODE' || (this.tree.contextMenu && this.tree.contextMenu.containerViewChild?.nativeElement.style.display === 'block')) { return; } From a02b08c4c19bae5d1805a40aeb4714e9fbe2965a Mon Sep 17 00:00:00 2001 From: joseph rosenthal Date: Tue, 26 Sep 2023 11:46:39 -0400 Subject: [PATCH 2/4] properly fix issue #13361 merge pull request #13392 fixed issue #13361 but caused filters not to automatically close when clicking different filter buttons. This change properly fixes issue #13361 and as a result fixes the bug that was induced by the original attempted fix. Instead of stopping the click event propagation, the isFilterElement method is improved by calling a new isFilterElementIconOrButton method --- src/app/components/table/table.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app/components/table/table.ts b/src/app/components/table/table.ts index 7b381c1966b..cb7a8620200 100644 --- a/src/app/components/table/table.ts +++ b/src/app/components/table/table.ts @@ -3338,7 +3338,7 @@ export class SortableColumn implements OnInit, OnDestroy { @HostListener('click', ['$event']) onClick(event: MouseEvent) { - if (this.isEnabled()) { + if (this.isEnabled() && !this.isFilterElement(event.target)) { this.updateSortState(); this.dt.sort({ originalEvent: event, @@ -3358,6 +3358,13 @@ export class SortableColumn implements OnInit, OnDestroy { return this.pSortableColumnDisabled !== true; } + isFilterElement(element: HTMLElement) { + return this.isFilterElementIconOrButton(element) || this.isFilterElementIconOrButton(element?.parentElement?.parentElement); + } + private isFilterElementIconOrButton(element: HTMLElement) { + return DomHandler.hasClass(element, 'pi-filter-icon') || DomHandler.hasClass(element, 'p-column-filter-menu-button'); + } + ngOnDestroy() { if (this.subscription) { this.subscription.unsubscribe(); @@ -4777,7 +4784,7 @@ export class ReorderableRow implements AfterViewInit { aria-haspopup="true" [attr.aria-expanded]="overlayVisible" [ngClass]="{ 'p-column-filter-menu-button-open': overlayVisible, 'p-column-filter-menu-button-active': hasFilter() }" - (click)="toggleMenu($event)" + (click)="toggleMenu()" (keydown)="onToggleButtonKeyDown($event)" > @@ -5108,9 +5115,8 @@ export class ColumnFilter implements AfterContentInit { } } - toggleMenu(event: any) { + toggleMenu() { this.overlayVisible = !this.overlayVisible; - event.stopPropagation(); } onToggleButtonKeyDown(event: KeyboardEvent) { From 55966637778f6efab0fc3d91afb498d86b7575d6 Mon Sep 17 00:00:00 2001 From: Jackson Bush Date: Tue, 26 Sep 2023 13:55:34 -0400 Subject: [PATCH 3/4] Another fix for #13034. Breaking out early in the align() method when the confirmation is null. --- src/app/components/confirmpopup/confirmpopup.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/app/components/confirmpopup/confirmpopup.ts b/src/app/components/confirmpopup/confirmpopup.ts index 0ac93b909cb..04d7e76183f 100755 --- a/src/app/components/confirmpopup/confirmpopup.ts +++ b/src/app/components/confirmpopup/confirmpopup.ts @@ -272,6 +272,9 @@ export class ConfirmPopup implements AfterContentInit, OnDestroy { ZIndexUtils.set('overlay', this.container, this.config.zIndex.overlay); } + if (!this.confirmation) { + return; + } DomHandler.absolutePosition(this.container, this.confirmation?.target); const containerOffset = DomHandler.getOffset(this.container); From 0bc0813a4b5e6c9a811e634962f442791908ecf2 Mon Sep 17 00:00:00 2001 From: Cameron Batt Date: Wed, 27 Sep 2023 20:34:52 +1000 Subject: [PATCH 4/4] Fix MegaMenu in jest using forwardRef --- src/app/components/megamenu/megamenu.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/components/megamenu/megamenu.ts b/src/app/components/megamenu/megamenu.ts index d351c273b92..0934fb18ca8 100755 --- a/src/app/components/megamenu/megamenu.ts +++ b/src/app/components/megamenu/megamenu.ts @@ -20,6 +20,7 @@ import { ViewChild, ViewEncapsulation, effect, + forwardRef, signal } from '@angular/core'; import { RouterModule } from '@angular/router'; @@ -226,7 +227,7 @@ export class MegaMenuSub { @ViewChild('menubar', { static: true }) menubarViewChild: ElementRef; - constructor(public el: ElementRef, public megaMenu: MegaMenu) {} + constructor(public el: ElementRef, @Inject(forwardRef(() => MegaMenu)) public megaMenu: MegaMenu) {} onItemClick(event: any, processedItem: any) { this.getItemProp(processedItem, 'command', { originalEvent: event, item: processedItem.item });