12982: update close guard condition

- Execute the close method only when the current context modal is opened
This commit is contained in:
Ahmed Ejaz
2024-11-28 03:12:11 +05:00
parent a493d70f5c
commit 1dec3debe1

View File

@@ -12,8 +12,8 @@ export const useOpenAndCloseAsAModal = (controller) => {
}.bind(controller),
close: function (_event, remove = false) {
// Only execute close if there is an open modal
if (!document.querySelector("body").classList.contains('modal-open')) return;
// Only execute close if the current modal is open
if (!this.modalTarget.classList.contains('in')) return;
this.modalTarget.classList.remove("in");
this.backgroundTarget.classList.remove("in");