Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #5579 from WebsiteDeveloper/dialog-improvements
Browse files Browse the repository at this point in the history
Remove modal-wrapper whenever modal dialog is closed
  • Loading branch information
redmunds committed Oct 23, 2013
2 parents 72e3ad0 + d79cc5e commit c131fbc
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/widgets/Dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ define(function (require, exports, module) {
function _dismissDialog($dlg, buttonId) {
$dlg.data("buttonId", buttonId);
$dlg.modal("hide");
$(".modal-wrapper:last").remove();
}

/**
Expand Down Expand Up @@ -120,9 +119,10 @@ define(function (require, exports, module) {
* @return {boolean}
*/
var _keydownHook = function (e, autoDismiss) {
var $primaryBtn = this.find(".primary"),
buttonId = null,
which = String.fromCharCode(e.which);
var $primaryBtn = this.find(".primary"),
buttonId = null,
which = String.fromCharCode(e.which),
$focusedElement = this.find(".dialog-button:focus, a:focus");

// There might be a textfield in the dialog's UI; don't want to mistake normal typing for dialog dismissal
var inTextArea = (e.target.tagName === "TEXTAREA"),
Expand All @@ -133,11 +133,11 @@ define(function (require, exports, module) {
} else if (e.which === KeyEvent.DOM_VK_ESCAPE) {
buttonId = DIALOG_BTN_CANCEL;
} else if (e.which === KeyEvent.DOM_VK_RETURN && !inTextArea) { // enter key in single-line text input still dismisses
// Click primary button
// Click primary
$primaryBtn.click();
} else if (e.which === KeyEvent.DOM_VK_SPACE) {
// Space bar on focused button or link
this.find(".dialog-button:focus, a:focus").click();
$focusedElement.click();
} else if (brackets.platform === "mac") {
// CMD+D Don't Save
if (e.metaKey && (which === "D")) {
Expand Down Expand Up @@ -259,6 +259,9 @@ define(function (require, exports, module) {

// Remove our global keydown handler.
KeyBindingManager.removeGlobalKeydownHook(keydownHook);

//Remove wrapper
$(".modal-wrapper:last").remove();
}).one("shown", function () {
// Set focus to the default button
var primaryBtn = $dlg.find(".primary");
Expand Down

0 comments on commit c131fbc

Please sign in to comment.