From 906bfdebeab3cd4c1e1a64a0afe0e0722036c7e9 Mon Sep 17 00:00:00 2001 From: David Battersby Date: Wed, 2 Aug 2023 17:15:08 +0800 Subject: [PATCH] FIX: prevent event bubbling when closing modals with escape key (#22928) This change prevents event bubbling for the Escape key on all modals. Currently when we close the modal using the Escape key, all other event listeners attached will also be triggered (such as closing the chat drawer if it's open). --- app/assets/javascripts/discourse/app/components/d-modal.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/discourse/app/components/d-modal.js b/app/assets/javascripts/discourse/app/components/d-modal.js index c262a3b979a..6f829604f53 100644 --- a/app/assets/javascripts/discourse/app/components/d-modal.js +++ b/app/assets/javascripts/discourse/app/components/d-modal.js @@ -86,6 +86,7 @@ export default class DModal extends Component { } if (event.key === "Escape" && this.dismissable) { + event.stopPropagation(); this.args.closeModal({ initiatedBy: CLOSE_INITIATED_BY_ESC }); }