dialog_widget: Fix race focusing submit button.

Opening the modal before adding the on_shown handler makes it possible
that the modal could full appear before the handler runs.
This commit is contained in:
Tim Abbott
2021-07-14 13:13:43 -07:00
parent 6fb0d414b4
commit e0135e278d

View File

@@ -131,12 +131,12 @@ export function launch(conf) {
dialog.remove(); dialog.remove();
}); });
// Open the modal
overlays.open_modal("#dialog_widget_modal");
if (conf.focus_submit_on_open) { if (conf.focus_submit_on_open) {
conf.parent.on("shown.bs.modal", () => { conf.parent.on("shown.bs.modal", () => {
submit_button.trigger("focus"); submit_button.trigger("focus");
}); });
} }
// Open the modal
overlays.open_modal("#dialog_widget_modal");
} }