@@ -1044,7 +1044,7 @@ define(function (require, exports, module) {
10441044 expect ( panel1 . isVisible ( ) ) . toBeFalse ( ) ;
10451045 } ) ;
10461046
1047- it ( "should not toggle bottom panel back on subsequent escape" , async function ( ) {
1047+ it ( "should toggle bottom panel back on subsequent escape" , async function ( ) {
10481048 panel1 . show ( ) ;
10491049 expect ( panel1 . isVisible ( ) ) . toBeTrue ( ) ;
10501050
@@ -1055,28 +1055,54 @@ define(function (require, exports, module) {
10551055 SpecRunnerUtils . simulateKeyEvent ( KeyEvent . DOM_VK_ESCAPE , "keydown" , _$ ( "#editor-holder" ) [ 0 ] ) ;
10561056 expect ( panel1 . isVisible ( ) ) . toBeFalse ( ) ;
10571057 SpecRunnerUtils . simulateKeyEvent ( KeyEvent . DOM_VK_ESCAPE , "keydown" , _$ ( "#editor-holder" ) [ 0 ] ) ;
1058- expect ( panel1 . isVisible ( ) ) . toBeFalse ( ) ;
1058+ expect ( panel1 . isVisible ( ) ) . toBeTrue ( ) ;
10591059 } ) ;
10601060
1061- it ( "should shift-escape also collapse bottom panel" , async function ( ) {
1061+ it ( "should shift-escape focus active panel instead of collapsing " , async function ( ) {
10621062 panel1 . show ( ) ;
10631063 expect ( panel1 . isVisible ( ) ) . toBeTrue ( ) ;
10641064
1065+ let focusCalled = false ;
1066+ panel1 . focus = function ( ) {
1067+ focusCalled = true ;
1068+ return true ;
1069+ } ;
1070+
10651071 expect ( MainViewManager . getActivePaneId ( ) ) . toEqual ( "first-pane" ) ;
10661072 promise = MainViewManager . _open ( MainViewManager . FIRST_PANE , FileSystem . getFileForPath ( testPath + "/test.js" ) ) ;
10671073 await awaitsForDone ( promise , "MainViewManager.doOpen" ) ;
10681074
10691075 SpecRunnerUtils . simulateKeyEvent ( KeyEvent . DOM_VK_ESCAPE , "keydown" , _$ ( "#editor-holder" ) [ 0 ] , {
10701076 shiftKey : true
10711077 } ) ;
1072- expect ( panel1 . isVisible ( ) ) . toBeFalse ( ) ;
1078+ // Shift+Escape should focus the panel, not collapse it
1079+ expect ( panel1 . isVisible ( ) ) . toBeTrue ( ) ;
1080+ expect ( focusCalled ) . toBeTrue ( ) ;
1081+ delete panel1 . focus ;
10731082 } ) ;
10741083
1075- it ( "should shift-escape collapse bottom panel regardless of canBeShown" , async function ( ) {
1084+ it ( "should shift-escape from panel focus the editor" , async function ( ) {
1085+ expect ( MainViewManager . getActivePaneId ( ) ) . toEqual ( "first-pane" ) ;
1086+ promise = MainViewManager . _open ( MainViewManager . FIRST_PANE , FileSystem . getFileForPath ( testPath + "/test.js" ) ) ;
1087+ await awaitsForDone ( promise , "MainViewManager.doOpen" ) ;
1088+
10761089 panel1 . show ( ) ;
1077- panel2 . registerCanBeShownHandler ( function ( ) {
1078- return false ;
1079- } ) ;
1090+ expect ( panel1 . isVisible ( ) ) . toBeTrue ( ) ;
1091+
1092+ // Blur the editor so getFocusedEditor() returns null
1093+ _$ ( "#some-panel1" ) [ 0 ] . setAttribute ( "tabindex" , "-1" ) ;
1094+ _$ ( "#some-panel1" ) [ 0 ] . focus ( ) ;
1095+ expect ( EditorManager . getFocusedEditor ( ) ) . toBeFalsy ( ) ;
1096+
1097+ SpecRunnerUtils . simulateKeyEvent ( KeyEvent . DOM_VK_ESCAPE , "keydown" ,
1098+ _$ ( "#editor-holder" ) [ 0 ] , { shiftKey : true } ) ;
1099+ // Editor should regain focus
1100+ expect ( EditorManager . getFocusedEditor ( ) ) . toBeTruthy ( ) ;
1101+ } ) ;
1102+
1103+ it ( "should shift-escape open default panel when no panel is visible" , async function ( ) {
1104+ panel1 . hide ( ) ;
1105+ panel2 . hide ( ) ;
10801106
10811107 expect ( MainViewManager . getActivePaneId ( ) ) . toEqual ( "first-pane" ) ;
10821108 promise = MainViewManager . _open ( MainViewManager . FIRST_PANE , FileSystem . getFileForPath ( testPath + "/test.js" ) ) ;
@@ -1085,8 +1111,62 @@ define(function (require, exports, module) {
10851111 SpecRunnerUtils . simulateKeyEvent ( KeyEvent . DOM_VK_ESCAPE , "keydown" , _$ ( "#editor-holder" ) [ 0 ] , {
10861112 shiftKey : true
10871113 } ) ;
1088- expect ( panel1 . isVisible ( ) ) . toBeFalse ( ) ;
1089- panel2 . registerCanBeShownHandler ( null ) ;
1114+ // A panel should now be visible (the default/quick access panel)
1115+ let defaultPanel = WorkspaceManager . getPanelForID ( WorkspaceManager . DEFAULT_PANEL_ID ) ;
1116+ expect ( defaultPanel . isVisible ( ) ) . toBeTrue ( ) ;
1117+ defaultPanel . hide ( ) ;
1118+ } ) ;
1119+
1120+ it ( "should shift-escape focus panel with custom focus handler" , async function ( ) {
1121+ // Create a panel with a text input that accepts focus
1122+ let focusPanelTemplate = `<div id="focus-test-panel" class="bottom-panel vert-resizable top-resizer">
1123+ <input id="focus-test-input" type="text" />
1124+ </div>` ;
1125+ let focusPanel = WorkspaceManager . createBottomPanel ( "focusTestPanel" ,
1126+ _$ ( focusPanelTemplate ) , 100 ) ;
1127+
1128+ focusPanel . focus = function ( ) {
1129+ _$ ( "#focus-test-input" ) [ 0 ] . focus ( ) ;
1130+ return true ;
1131+ } ;
1132+
1133+ focusPanel . show ( ) ;
1134+ expect ( focusPanel . isVisible ( ) ) . toBeTrue ( ) ;
1135+
1136+ expect ( MainViewManager . getActivePaneId ( ) ) . toEqual ( "first-pane" ) ;
1137+ promise = MainViewManager . _open ( MainViewManager . FIRST_PANE , FileSystem . getFileForPath ( testPath + "/test.js" ) ) ;
1138+ await awaitsForDone ( promise , "MainViewManager.doOpen" ) ;
1139+
1140+ // Shift+Escape from editor should focus the panel's text input
1141+ SpecRunnerUtils . simulateKeyEvent ( KeyEvent . DOM_VK_ESCAPE , "keydown" ,
1142+ _$ ( "#editor-holder" ) [ 0 ] , { shiftKey : true } ) ;
1143+ expect ( testWindow . document . activeElement ) . toBe ( _$ ( "#focus-test-input" ) [ 0 ] ) ;
1144+
1145+ // Shift+Escape from panel should focus the editor
1146+ SpecRunnerUtils . simulateKeyEvent ( KeyEvent . DOM_VK_ESCAPE , "keydown" ,
1147+ _$ ( "#editor-holder" ) [ 0 ] , { shiftKey : true } ) ;
1148+ expect ( EditorManager . getFocusedEditor ( ) ) . toBeTruthy ( ) ;
1149+
1150+ focusPanel . hide ( ) ;
1151+ WorkspaceManager . destroyBottomPanel ( "focusTestPanel" ) ;
1152+ } ) ;
1153+
1154+ it ( "should app-drawer-button toggle the default panel" , async function ( ) {
1155+ panel1 . hide ( ) ;
1156+ panel2 . hide ( ) ;
1157+ let defaultPanel = WorkspaceManager . getPanelForID ( WorkspaceManager . DEFAULT_PANEL_ID ) ;
1158+ if ( defaultPanel . isVisible ( ) ) {
1159+ defaultPanel . hide ( ) ;
1160+ }
1161+ expect ( defaultPanel . isVisible ( ) ) . toBeFalse ( ) ;
1162+
1163+ // Click app-drawer-button to show the default panel
1164+ _$ ( "#app-drawer-button" ) . click ( ) ;
1165+ expect ( defaultPanel . isVisible ( ) ) . toBeTrue ( ) ;
1166+
1167+ // Click again to hide it
1168+ _$ ( "#app-drawer-button" ) . click ( ) ;
1169+ expect ( defaultPanel . isVisible ( ) ) . toBeFalse ( ) ;
10901170 } ) ;
10911171
10921172 it ( "should escape collapse bottom panel regardless of canBeShown" , async function ( ) {
0 commit comments