Skip to content

Commit

Permalink
OverlayPanel: Fix regression primefaces#13605 & primefaces#13601 dete…
Browse files Browse the repository at this point in the history
…ct click on scrollbar, prevent hiding e.g. when selecting dropdown options
  • Loading branch information
anlampe committed Oct 5, 2023
1 parent bdecfee commit df9e56d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/app/components/overlaypanel/overlaypanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { Subscription } from 'rxjs';
role="dialog"
[attr.aria-modal]="overlayVisible"
>
<div class="p-overlaypanel-content" (click)="onContentClick()" (mousedown)="onContentClick()">
<div class="p-overlaypanel-content" (click)="onContentClick($event)" (mousedown)="onContentClick($event)">
<ng-content></ng-content>
<ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
</div>
Expand Down Expand Up @@ -229,10 +229,11 @@ export class OverlayPanel implements AfterContentInit, OnDestroy {
const documentTarget: any = this.el ? this.el.nativeElement.ownerDocument : this.document;

this.documentClickListener = this.renderer.listen(documentTarget, documentEvent, (event) => {
if (!this.container?.contains(event.target) && !this.target.contains(event.target)) {
if (!this.container?.contains(event.target) && !this.target.contains(event.target) && this.target !== event.target && !this.selfClick) {
this.hide();
}

this.selfClick = false;
this.cd.markForCheck();
});
}
Expand Down Expand Up @@ -297,8 +298,9 @@ export class OverlayPanel implements AfterContentInit, OnDestroy {
this.selfClick = true;
}

onContentClick() {
this.selfClick = true;
onContentClick(event: MouseEvent) {
const targetElement = event.target as HTMLElement;
this.selfClick = event.offsetX < targetElement.clientWidth && event.offsetY < targetElement.clientHeight;
}

hasTargetChanged(event: any, target: any) {
Expand Down

0 comments on commit df9e56d

Please sign in to comment.