Skip to content

Commit 551b177

Browse files
committed
feat: bottom panel doesnt open with the tab last closed
1 parent db12710 commit 551b177

3 files changed

Lines changed: 54 additions & 20 deletions

File tree

src/view/DefaultPanelView.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,18 @@ define(function (require, exports, module) {
198198
}
199199
});
200200

201-
// Update drawer button state based on bottom panel container visibility.
202-
// The app drawer icon stays selected whenever the bottom panel is visible.
201+
// Drawer button reflects whether the Quick Access (default) panel is
202+
// the active visible panel. _switchToTab silently swaps active tabs
203+
// without firing PANEL_HIDDEN for the previous one, so we have to gate
204+
// the SHOWN handler on the panelID — relying on a HIDDEN event would
205+
// miss the case where another tab takes over from Quick Access.
206+
// The minimize-button "stuck selected" case is handled by PanelView
207+
// firing PANEL_HIDDEN with the default panel id, picked up below.
203208
PanelView.on(PanelView.EVENT_PANEL_SHOWN, function (event, panelID) {
204209
if (panelID === WorkspaceManager.DEFAULT_PANEL_ID) {
205210
_updateButtonVisibility();
206211
}
207-
$drawerBtn.addClass("selected-button");
212+
$drawerBtn.toggleClass("selected-button", panelID === WorkspaceManager.DEFAULT_PANEL_ID);
208213
});
209214

210215
PanelView.on(PanelView.EVENT_PANEL_HIDDEN, function (event, panelID) {

src/view/PanelView.js

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -908,23 +908,12 @@ define(function (require, exports, module) {
908908
_showOverflowMenu();
909909
});
910910

911-
// Hide-panel button collapses the container but keeps tabs intact.
912-
// Maximize state is preserved so the panel re-opens maximized.
911+
// Hide-panel button collapses the container but keeps the active
912+
// panel logically active so re-opening (drawer / Escape) restores it
913+
// with its content already mounted.
913914
_$tabBar.on("click", ".bottom-panel-hide-btn", function (e) {
914915
e.stopPropagation();
915-
if (_$container && _$container.is(":visible")) {
916-
if (_activeId) {
917-
const activePanel = _panelMap[_activeId];
918-
if (activePanel) {
919-
activePanel.$panel.removeClass("active-bottom-panel");
920-
}
921-
}
922-
_activeId = null;
923-
_updateActiveTabHighlight();
924-
restoreIfMaximized();
925-
Resizer.hide(_$container[0]);
926-
exports.trigger(EVENT_PANEL_HIDDEN, _defaultPanelId);
927-
}
916+
collapseContainer();
928917
});
929918

930919
// Maximize/restore toggle button
@@ -1132,6 +1121,39 @@ define(function (require, exports, module) {
11321121
return _isMaximized;
11331122
}
11341123

1124+
/**
1125+
* Collapse the bottom panel container (transient hide) without touching
1126+
* which panel is logically active. Fires EVENT_PANEL_HIDDEN with the
1127+
* default panel id as a "container collapsed" signal so toolbar icons
1128+
* and menu items that mirror container visibility deselect.
1129+
* No-op if the container is already hidden.
1130+
*/
1131+
function collapseContainer() {
1132+
if (!_$container || !_$container.is(":visible")) {
1133+
return;
1134+
}
1135+
restoreIfMaximized();
1136+
Resizer.hide(_$container[0]);
1137+
exports.trigger(EVENT_PANEL_HIDDEN, _defaultPanelId);
1138+
}
1139+
1140+
/**
1141+
* Re-show the bottom panel container after a previous collapse, with the
1142+
* previously active panel still mounted. Fires EVENT_PANEL_SHOWN for the
1143+
* active panel id so toolbar icons / menu items that mirror visibility
1144+
* re-select. No-op if the container is already visible or there's no
1145+
* active panel to restore.
1146+
*/
1147+
function restoreContainer() {
1148+
if (!_$container || _$container.is(":visible")) {
1149+
return;
1150+
}
1151+
Resizer.show(_$container[0]);
1152+
if (_activeId) {
1153+
exports.trigger(EVENT_PANEL_SHOWN, _activeId);
1154+
}
1155+
}
1156+
11351157
/**
11361158
* Returns a copy of the currently open bottom panel IDs in tab order.
11371159
* @return {string[]}
@@ -1226,6 +1248,8 @@ define(function (require, exports, module) {
12261248
exports.restoreIfMaximized = restoreIfMaximized;
12271249
exports.isMaximized = isMaximized;
12281250
exports.MAXIMIZE_THRESHOLD = MAXIMIZE_THRESHOLD;
1251+
exports.collapseContainer = collapseContainer;
1252+
exports.restoreContainer = restoreContainer;
12291253
//events
12301254
exports.EVENT_PANEL_HIDDEN = EVENT_PANEL_HIDDEN;
12311255
exports.EVENT_PANEL_SHOWN = EVENT_PANEL_SHOWN;

src/view/WorkspaceManager.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,9 +812,14 @@ define(function (require, exports, module) {
812812
return false;
813813
}
814814
if ($bottomPanelContainer.is(":visible")) {
815-
Resizer.hide($bottomPanelContainer[0]);
815+
// Use the helper so HIDDEN(_defaultPanelId) fires — toolbar
816+
// buttons and menu items that mirror container visibility
817+
// (drawer, Git icon, etc.) need this signal to deselect.
818+
PanelView.collapseContainer();
816819
} else if (PanelView.getOpenBottomPanelIDs().length > 0) {
817-
Resizer.show($bottomPanelContainer[0]);
820+
// Use the helper so SHOWN(_activeId) fires — same listeners
821+
// need this signal to re-select after a previous collapse.
822+
PanelView.restoreContainer();
818823
} else {
819824
_showDefaultPanel();
820825
}

0 commit comments

Comments
 (0)