@@ -67,7 +67,11 @@ define(function (require, exports, module) {
67
67
buttonId = null ,
68
68
which = String . fromCharCode ( e . which ) ;
69
69
70
- if ( e . which === KeyEvent . DOM_VK_RETURN ) {
70
+ // There might be a textfield in the dialog's UI; don't want to mistake normal typing for dialog dismissal
71
+ var inFormField = ( $ ( e . target ) . filter ( ":input" ) . length > 0 ) ,
72
+ inTextArea = ( e . target . tagName === "TEXTAREA" ) ;
73
+
74
+ if ( e . which === KeyEvent . DOM_VK_RETURN && ! inTextArea ) { // enter key in single-line text input still dismisses
71
75
// Click primary button
72
76
if ( primaryBtn ) {
73
77
buttonId = primaryBtn . attr ( "data-button-id" ) ;
@@ -87,7 +91,7 @@ define(function (require, exports, module) {
87
91
}
88
92
} else { // if (brackets.platform === "win") {
89
93
// 'N' Don't Save
90
- if ( which === "N" ) {
94
+ if ( which === "N" && ! inFormField ) {
91
95
if ( _hasButton ( this , DIALOG_BTN_DONTSAVE ) ) {
92
96
buttonId = DIALOG_BTN_DONTSAVE ;
93
97
}
@@ -96,8 +100,7 @@ define(function (require, exports, module) {
96
100
97
101
if ( buttonId ) {
98
102
_dismissDialog ( this , buttonId ) ;
99
- } else if ( ! ( $ . contains ( this . get ( 0 ) , e . target ) ) ||
100
- ( $ ( e . target ) . filter ( ":input" ) . length === 0 ) ) {
103
+ } else if ( ! ( $ . contains ( this . get ( 0 ) , e . target ) ) || ! inFormField ) {
101
104
// Stop the event if the target is not inside the dialog
102
105
// or if the target is not a form element.
103
106
// TODO (issue #414): more robust handling of dialog scoped
0 commit comments