Skip to content

Commit

Permalink
fix(core/modal): backdrop static only dismisses modal on actual backd…
Browse files Browse the repository at this point in the history
…rop (#285)

Co-authored-by: Daniel Leroux <[email protected]>
  • Loading branch information
nuke-ellington and danielleroux authored Jan 11, 2023
1 parent 3d6ffd7 commit 6d55b93
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/core/src/components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,18 @@ export class Modal {
});
}

private onBackdropClick(event: Event) {
const target = event.target as Element;
if (target.classList.contains('backdrop')) {
this.dismiss(event);
}
}

componentDidLoad() {
if (this.backdrop === 'static') {
this.modalBackdrop.addEventListener('click', this.dismiss.bind(this));
this.modalBackdrop.addEventListener('click', (event) =>
this.onBackdropClick(event)
);
}

if (this.backdropClass) {
Expand Down

0 comments on commit 6d55b93

Please sign in to comment.