-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Remove modal-wrapper whenever modal dialog is closed #5579
Changes from 4 commits
4680443
a0f4b15
a0649c6
0d76828
c252576
d79cc5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,7 +69,6 @@ define(function (require, exports, module) { | |
| function _dismissDialog($dlg, buttonId) { | ||
| $dlg.data("buttonId", buttonId); | ||
| $dlg.modal("hide"); | ||
| $(".modal-wrapper:last").remove(); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -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"), | ||
|
|
@@ -133,11 +133,17 @@ 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 | ||
| $primaryBtn.click(); | ||
| // Click focused button or primary if no focus | ||
| if($focusedElement.length !== 0) { | ||
| $focusedElement.click(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RaymondLim brought up a good point (offline), so I'll comment here for him. Focused element should only receive click with space-bar, not Enter key.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought about that too, but it is the default behavior in chrome and firefox so i decided to add it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that seems to be the case. I'll wait until @RaymondLim responds.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @WebsiteDeveloper Regarding your claim of default behavior in chrome and firefox, I'm not sure you're referring to any modal dialog that has that behavior. Let me know if you see that behavior in any modal dialog and not in a web page.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will check tomorrow as it's already late here in germany
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will rechange it. |
||
| } else { | ||
| $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(); | ||
| if($focusedElement.length !== 0) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JSLint: Expected exactly one space between 'if' and '('. |
||
| $focusedElement.click(); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need to check length here. If there is no focused element, then nothing happens, so you should change: to: |
||
| } else if (brackets.platform === "mac") { | ||
| // CMD+D Don't Save | ||
| if (e.metaKey && (which === "D")) { | ||
|
|
@@ -259,6 +265,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"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSLint: Expected exactly one space between 'if' and '('.