From d9aa105c8ea2229220ed9e984ba936f06851148d Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Fri, 11 Sep 2020 16:00:31 +0200 Subject: [PATCH] FIX: wrap modal onShow inside next (#10651) Before this commit, onShow code could be impacted by code happening after the onShow call. This should ensure this code works for example: ``` onShow() { afterRender(() => { someInput.focus(); }) } ``` --- app/assets/javascripts/discourse/app/lib/show-modal.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/lib/show-modal.js b/app/assets/javascripts/discourse/app/lib/show-modal.js index f2602e01969..a550b2f73c0 100644 --- a/app/assets/javascripts/discourse/app/lib/show-modal.js +++ b/app/assets/javascripts/discourse/app/lib/show-modal.js @@ -1,3 +1,4 @@ +import { next } from "@ember/runloop"; import I18n from "I18n"; import { dasherize } from "@ember/string"; import { getOwner } from "discourse-common/lib/get-owner"; @@ -72,7 +73,7 @@ export default function (name, opts) { controller.set("model", model); } if (controller.onShow) { - controller.onShow(); + next(() => controller.onShow()); } controller.set("flashMessage", null);