Skip to content

Commit

Permalink
feat(modal): lock body scrolling while modal is open
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyzerner committed Nov 6, 2023
1 parent fe57357 commit 59e693d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/modal/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ export default class ModalElement extends HTMLElement {
}

private async wasOpened() {
document.documentElement.style.overflow = 'hidden';

this.hidden = false;

hello(this);
Expand All @@ -127,6 +129,8 @@ export default class ModalElement extends HTMLElement {
}

private wasClosed() {
document.documentElement.style.overflow = '';

this.focusTrap?.deactivate();

goodbye(this).then(() => (this.hidden = true));
Expand Down

0 comments on commit 59e693d

Please sign in to comment.