diff --git a/app/assets/javascripts/discourse/lib/show-modal.js.es6 b/app/assets/javascripts/discourse/lib/show-modal.js.es6 index 8b865ce2011..675a0e37f84 100644 --- a/app/assets/javascripts/discourse/lib/show-modal.js.es6 +++ b/app/assets/javascripts/discourse/lib/show-modal.js.es6 @@ -39,6 +39,7 @@ export default function(name, opts) { modalController.set("modalClass", opts.modalClass); const controllerName = opts.admin ? `modals/${name}` : name; + modalController.set("name", controllerName); let controller = container.lookup("controller:" + controllerName); const templateName = opts.templateName || Ember.String.dasherize(name); diff --git a/app/assets/javascripts/discourse/routes/application.js.es6 b/app/assets/javascripts/discourse/routes/application.js.es6 index a161f09542c..05777861911 100644 --- a/app/assets/javascripts/discourse/routes/application.js.es6 +++ b/app/assets/javascripts/discourse/routes/application.js.es6 @@ -144,6 +144,13 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, { // Close the current modal, and destroy its state. closeModal() { this.render("hide-modal", { into: "modal", outlet: "modalBody" }); + + const route = getOwner(this).lookup("route:application"); + const name = route.controllerFor("modal").get("name"); + const controller = getOwner(this).lookup(`controller:${name}`); + if (controller && controller.onClose) { + controller.onClose(); + } }, /**