mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-24 05:38:52 +00:00
Dispatch "closing" event when closing modal
This allow for any other controller to trigger an action when the modal is closed
This commit is contained in:
@@ -12,8 +12,10 @@ export const useOpenAndCloseAsAModal = (controller) => {
|
||||
}.bind(controller),
|
||||
|
||||
close: function (_event, remove = false) {
|
||||
// displatch closing event so other controller can trigger action when the modal closes
|
||||
this.dispatch("closing");
|
||||
// Only execute close if the current modal is open
|
||||
if (!this.modalTarget.classList.contains('in')) return;
|
||||
if (!this.modalTarget.classList.contains("in")) return;
|
||||
|
||||
this.modalTarget.classList.remove("in");
|
||||
this.backgroundTarget.classList.remove("in");
|
||||
@@ -22,7 +24,9 @@ export const useOpenAndCloseAsAModal = (controller) => {
|
||||
setTimeout(() => {
|
||||
this.backgroundTarget.style.display = "none";
|
||||
this.modalTarget.style.display = "none";
|
||||
if (remove) { this.element.remove() }
|
||||
if (remove) {
|
||||
this.element.remove();
|
||||
}
|
||||
}, 200);
|
||||
}.bind(controller),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user