1
0
mirror of https://github.com/adobe/brackets.git synced 2024-11-20 18:02:54 +01:00

Merge pull request #7677 from adobe/tom/issue-7598

Fix 7598: showModalDialogUsingTemplate doesn't blur current editor
This commit is contained in:
Narciso Jaramillo 2014-06-03 19:46:54 -04:00
commit 9bbfceaaf5

View File

@ -272,10 +272,11 @@ define(function (require, exports, module) {
$("body").append("<div class='modal-wrapper'><div class='modal-inner-wrapper'></div></div>");
var result = $.Deferred(),
promise = result.promise(),
$dlg = $(template)
var result = new $.Deferred(),
promise = result.promise(),
$dlg = $(template)
.addClass("instance")
.prop("tabindex", "-1")
.appendTo(".modal-inner-wrapper:last");
// Don't allow dialog to exceed viewport size
@ -311,11 +312,17 @@ define(function (require, exports, module) {
//Remove wrapper
$(".modal-wrapper:last").remove();
}).one("shown", function () {
// Set focus to the default button
var primaryBtn = $dlg.find(".primary");
var $primaryBtn = $dlg.find(".primary:enabled"),
$otherBtn = $dlg.find(".modal-footer .dialog-button:enabled:eq(0)");
if (primaryBtn) {
primaryBtn.focus();
// Set focus to the primary button, to any other button, or to the dialog depending
// if there are buttons
if ($primaryBtn.length) {
$primaryBtn.focus();
} else if ($otherBtn.length) {
$otherBtn.focus();
} else {
$dlg.focus();
}
// Push our global keydown handler onto the global stack of handlers.