Skip to content

Commit

Permalink
feat(modal): manage body overflow with SCSS rather than JS
Browse files Browse the repository at this point in the history
  • Loading branch information
Leotheluck authored and dpellier committed Jul 29, 2024
1 parent 032ae9f commit 43afb8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
display: flex;
}

body:has(dialog[open]) {
overflow: hidden;
}

.ods-modal {
&__dialog {
@include modal.ods-modal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export class OdsModal {

@Method()
async close(): Promise<void> {
document.body.style.removeProperty('overflow');

if (this.modalDialog) {
this.modalDialog.classList.add('ods-modal__dialog--close-animation');
Expand All @@ -42,7 +41,6 @@ export class OdsModal {

@Method()
async open(): Promise<void> {
document.body.style.overflow = 'hidden';
this.isOpen = true;
this.modalDialog.focus();
this.odsModalOpen.emit();
Expand Down Expand Up @@ -78,7 +76,6 @@ export class OdsModal {
}

disconnectedCallback(): void {
document.body.style.removeProperty('overflow');
this.modalDialog.close?.();
this.isOpen = false;
this.odsModalClose.emit();
Expand Down

0 comments on commit 43afb8e

Please sign in to comment.