Skip to content

Commit a6bdd98

Browse files
committed
Fix bug in chrome where clicking with an open modal triggers a click on an <a> ancestor, even if the dialog stops event propagation in a handler
1 parent 00f5940 commit a6bdd98

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

evap/static/ts/src/confirmation-modal.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ export class ConfirmationModal extends HTMLElement {
2525
confirmButton.className += " " + confirmButtonExtraClass;
2626

2727
const showButton = selectOrError("[slot=show-button]", this);
28-
showButton.addEventListener("click", () => this.dialog.showModal());
28+
showButton.addEventListener("click", event => {
29+
event.stopPropagation();
30+
this.dialog.showModal();
31+
});
2932
const updateDisabledAttribute = () => {
3033
this.toggleAttribute("disabled", showButton.hasAttribute("disabled"));
3134
};
@@ -36,6 +39,8 @@ export class ConfirmationModal extends HTMLElement {
3639

3740
this.dialogForm = selectOrError("form[method=dialog]", this.dialog);
3841
this.dialogForm.addEventListener("submit", this.onDialogFormSubmit);
42+
43+
this.dialog.addEventListener("click", event => event.stopPropagation());
3944
}
4045

4146
onDialogFormSubmit = (event: SubmitEvent) => {

0 commit comments

Comments
 (0)