Skip to content

Commit cef10f2

Browse files
devvaannshabose
authored andcommitted
fix: tab bar disappearing bug
1 parent 5f4655e commit cef10f2

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

src/extensionsIntegrated/TabBar/main.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,9 @@ define(function (require, exports, module) {
233233

234234
if ($('.not-editor').length === 1) {
235235
$tabBar = $(TabBarHTML);
236-
// since we need to add the tab bar before the editor area, we target the `#editor-holder` class and prepend
237-
$("#editor-holder").prepend($tabBar);
236+
// since we need to add the tab bar before the editor which has .not-editor class
237+
// we target the `.not-editor` class and add the tab bar before it
238+
$(".not-editor").before($tabBar);
238239
setTimeout(function () {
239240
WorkspaceManager.recomputeLayout(true);
240241
}, 0);
@@ -452,9 +453,13 @@ define(function (require, exports, module) {
452453
* Registers the event handlers
453454
*/
454455
function registerHandlers() {
455-
// For pane changes, still recreate the entire tab bar container.
456-
MainViewManager.off("activePaneChange paneCreate paneDestroy paneLayoutChange", createTabBar);
457-
MainViewManager.on("activePaneChange paneCreate paneDestroy paneLayoutChange", createTabBar);
456+
// For pane layout changes, recreate the entire tab bar container
457+
MainViewManager.off("paneCreate paneDestroy paneLayoutChange", createTabBar);
458+
MainViewManager.on("paneCreate paneDestroy paneLayoutChange", createTabBar);
459+
460+
// For active pane changes, update only the tabs
461+
MainViewManager.off("activePaneChange", updateTabs);
462+
MainViewManager.on("activePaneChange", updateTabs);
458463

459464
// For editor changes, update only the tabs.
460465
EditorManager.off("activeEditorChange", updateTabs);
@@ -474,16 +479,15 @@ define(function (require, exports, module) {
474479
MainViewManager.off(events.join(" "), updateTabs);
475480
MainViewManager.on(events.join(" "), updateTabs);
476481

477-
// When the sidebar UI changes, update the tabs to ensure the overflow menu is correct.
478-
// Without this, if the sidebar is hidden, and **all tabs become visible**, the overflow icon still appears.
482+
// When the sidebar UI changes, update the tabs to ensure the overflow menu is correct
479483
$("#sidebar").off("panelCollapsed panelExpanded panelResizeEnd", updateTabs);
480484
$("#sidebar").on("panelCollapsed panelExpanded panelResizeEnd", updateTabs);
481485

482486
// also update the tabs when the main plugin panel resizes
483487
// main-plugin-panel[0] = live preview panel
484488
new ResizeObserver(updateTabs).observe($("#main-plugin-panel")[0]);
485489

486-
// file dirty flag change remains unchanged.
490+
// File dirty flag change handling
487491
DocumentManager.on("dirtyFlagChange", function (event, doc) {
488492
const filePath = doc.file.fullPath;
489493

src/extensionsIntegrated/TabBar/overflow.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,20 @@ define(function (require, exports, module) {
249249
// get the current scroll position
250250
const currentScroll = $tabBarElement.scrollLeft();
251251

252-
// Adjust scroll position if the tab is off-screen
252+
// animate the scroll change over 5 for a very fast effect
253253
if (tabLeftRelative < 0) {
254-
// tab is too far to the left
255-
$tabBarElement.scrollLeft(currentScroll + tabLeftRelative - 10); // 10px padding
254+
// Tab is too far to the left
255+
$tabBarElement.animate(
256+
{ scrollLeft: currentScroll + tabLeftRelative - 10 },
257+
5
258+
);
256259
} else if (tabRightRelative > tabBarVisibleWidth) {
257-
// tab is too far to the right
258-
const scrollAdjustment = tabRightRelative - tabBarVisibleWidth + 10; // 10px padding
259-
$tabBarElement.scrollLeft(currentScroll + scrollAdjustment);
260+
// Tab is too far to the right
261+
const scrollAdjustment = tabRightRelative - tabBarVisibleWidth + 10;
262+
$tabBarElement.animate(
263+
{ scrollLeft: currentScroll + scrollAdjustment },
264+
5
265+
);
260266
}
261267
}
262268
}

0 commit comments

Comments
 (0)