Skip to content

Commit

Permalink
Merge pull request #15845 from primefaces/issue-15779
Browse files Browse the repository at this point in the history
Fixed #15779 - Closing nested dialog removes CSS class still needed f…
  • Loading branch information
cetincakiroglu committed Jun 27, 2024
2 parents 2901f73 + 9fde4f3 commit a3af939
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/app/components/dynamicdialog/dynamicdialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export class DynamicDialogComponent implements AfterViewInit, OnDestroy {

get parent() {
const domElements = Array.from(this.document.getElementsByClassName('p-dialog'));

if (domElements.length > 1) {
return domElements.pop();
}
Expand Down Expand Up @@ -266,6 +267,13 @@ export class DynamicDialogComponent implements AfterViewInit, OnDestroy {
return this.config?.templates?.closeicon;
}

get dynamicDialogCount() {
const dynamicDialogs = this.document.querySelectorAll('p-dynamicdialog');
const dynamicDialogCount = dynamicDialogs?.length;

return dynamicDialogCount;
}

constructor(
@Inject(DOCUMENT) private document: Document,
@Inject(PLATFORM_ID) private platformId: any,
Expand Down Expand Up @@ -305,6 +313,7 @@ export class DynamicDialogComponent implements AfterViewInit, OnDestroy {
}
}
}

destroyStyle() {
if (this.styleElement) {
this.renderer.removeChild(this.document.head, this.styleElement);
Expand Down Expand Up @@ -409,7 +418,7 @@ export class DynamicDialogComponent implements AfterViewInit, OnDestroy {
});
}

if (this.config.modal !== false) {
if (this.dynamicDialogCount === 1) {
DomHandler.addClass(this.document.body, 'p-overflow-hidden');
}
}
Expand All @@ -419,8 +428,7 @@ export class DynamicDialogComponent implements AfterViewInit, OnDestroy {
if (this.config.dismissableMask) {
this.unbindMaskClickListener();
}

if (this.config.modal !== false) {
if (this.dynamicDialogCount === 1) {
DomHandler.removeClass(this.document.body, 'p-overflow-hidden');
}

Expand Down

0 comments on commit a3af939

Please sign in to comment.