Skip to content

Commit 8f906ed

Browse files
Fix page scroll while dialog open
1 parent b074ec7 commit 8f906ed

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

projects/ngsuite/src/lib/dialog/services/Dialog.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import { Observable, throwError } from "rxjs";
1010
const DialogInstances: NGSuiteDialogInstance[] = [];
1111
const DialogRootMap = new Map<NGSuiteDialog, NGSuiteDialogRoot>();
1212

13-
@Injectable()
13+
@Injectable({
14+
providedIn: 'root',
15+
})
1416
export class NGSuiteDialog {
1517

1618
constructor() {
@@ -74,15 +76,18 @@ export class NGSuiteDialog {
7476
instance.afterClosed.subscribe(() => {
7577
const index = DialogInstances.indexOf(instance);
7678
DialogInstances.splice(index, 1);
79+
80+
const hasInstances = DialogInstances.length > 0;
81+
document.body.classList.toggle('ngs-dialog-open', hasInstances);
7782
});
7883

7984
return instance;
8085
}
8186

8287
closeAll() {
8388
while (DialogInstances.length) {
84-
const instance = DialogInstances.pop() as NGSuiteDialogInstance;
85-
instance.close(false);
89+
const instance = DialogInstances.pop();
90+
instance?.close(false);
8691
}
8792
}
8893

projects/ngsuite/src/styles/features/dialog.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@
3333
font-weight: 500;
3434
}
3535
}
36+
37+
.ngs-dialog-open {
38+
overflow: clip !important;
39+
}

0 commit comments

Comments
 (0)