Skip to content

Commit edc73d0

Browse files
committed
fix: ui rendering issues with tab bar
1 parent 1727ef4 commit edc73d0

File tree

5 files changed

+37
-18
lines changed

5 files changed

+37
-18
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<div id="tab-bar-container" class="tab-bar-container">
1+
<div class="tab-bar-container">
22
<div id="phoenix-tab-bar" class="phoenix-tab-bar">
33

44
</div>
55

66
<div id="overflow-button" class="overflow-button" title="Show hidden tabs">
77
<i class="fa-solid fa-chevron-down"></i>
88
</div>
9-
</div>
9+
</div>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<div id="tab-bar-container" class="tab-bar-container">
1+
<div class="tab-bar-container">
22
<div id="phoenix-tab-bar-2" class="phoenix-tab-bar">
33

44
</div>
55

66
<div id="overflow-button-2" class="overflow-button-2" title="Show hidden tabs">
77
<i class="fa-solid fa-chevron-down"></i>
88
</div>
9-
</div>
9+
</div>

src/extensionsIntegrated/TabBar/main.js

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,21 +188,22 @@ define(function (require, exports, module) {
188188
// clean up any existing tab bars first and start fresh
189189
cleanupTabBar();
190190

191-
if ($('.not-editor').length === 1) {
191+
const $paneHeader = $('.pane-header');
192+
if ($paneHeader.length === 1) {
192193
$tabBar = $(TabBarHTML);
193194
// since we need to add the tab bar before the editor which has .not-editor class
194-
$(".not-editor").before($tabBar);
195+
$(".pane-header").after($tabBar);
195196
WorkspaceManager.recomputeLayout(true);
196197
updateTabs();
197198

198-
} else if ($('.not-editor').length === 2) {
199+
} else if ($paneHeader.length === 2) {
199200
$tabBar = $(TabBarHTML);
200201
$tabBar2 = $(TabBarHTML2);
201202

202203
// eq(0) is for the first pane and eq(1) is for the second pane
203204
// TODO: Fix bug where the tab bar gets hidden inside the editor in horizontal split
204-
$(".not-editor").eq(0).before($tabBar);
205-
$(".not-editor").eq(1).before($tabBar2);
205+
$paneHeader.eq(0).after($tabBar);
206+
$paneHeader.eq(1).after($tabBar2);
206207
WorkspaceManager.recomputeLayout(true);
207208
updateTabs();
208209
}
@@ -344,6 +345,7 @@ define(function (require, exports, module) {
344345
}
345346
// Also check for any orphaned tab bars that might exist
346347
$(".tab-bar-container").remove();
348+
WorkspaceManager.recomputeLayout(true);
347349
}
348350

349351

@@ -353,7 +355,7 @@ define(function (require, exports, module) {
353355
function handleTabClick() {
354356

355357
// delegate event handling for both tab bars
356-
$(document).on("click", ".tab", function (event) {
358+
$(document).on("click", ".phoenix-tab-bar .tab", function (event) {
357359
// check if the clicked element is the close button
358360
if ($(event.target).hasClass('fa-times') || $(event.target).closest('.tab-close').length) {
359361
// Get the file path from the data-path attribute of the parent tab
@@ -376,23 +378,35 @@ define(function (require, exports, module) {
376378
event.preventDefault();
377379
event.stopPropagation();
378380
}
379-
return;
380381
}
382+
});
381383

384+
// delegate event handling for both tab bars
385+
$(document).on("mousedown", ".phoenix-tab-bar .tab", function (event) {
386+
if ($(event.target).hasClass('fa-times') || $(event.target).closest('.tab-close').length) {
387+
return;
388+
}
382389
// Get the file path from the data-path attribute
383390
const filePath = $(this).attr("data-path");
384391

385392
if (filePath) {
386-
CommandManager.execute(Commands.FILE_OPEN, { fullPath: filePath });
393+
// determine the pane inside which the tab belongs
394+
const isSecondPane = $(this).closest("#phoenix-tab-bar-2").length > 0;
395+
const paneId = isSecondPane ? "second-pane" : "first-pane";
396+
const activeEditor = EditorManager.getActiveEditor();
397+
const currentActivePane = MainViewManager.getActivePaneId();
398+
const isPaneActive = (paneId === currentActivePane);
399+
if(isPaneActive && activeEditor && activeEditor.document.file.fullPath === filePath) {
400+
return;
401+
}
402+
CommandManager.execute(Commands.FILE_OPEN, { fullPath: filePath, paneId: paneId });
387403

388-
// Prevent default behavior
389-
event.preventDefault();
390-
event.stopPropagation();
404+
// We dont prevent default behavior here to enable drag and drop of this tab
391405
}
392406
});
393407

394408
// Add the contextmenu (right-click) handler
395-
$(document).on("contextmenu", ".tab", function (event) {
409+
$(document).on("contextmenu", ".phoenix-tab-bar .tab", function (event) {
396410
event.preventDefault();
397411
event.stopPropagation();
398412

src/nls/root/strings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ define({
554554
"CMD_HIDE_SIDEBAR": "Hide Sidebar",
555555
"CMD_SHOW_SIDEBAR": "Show Sidebar",
556556
"CMD_TOGGLE_SIDEBAR": "Toggle Sidebar",
557-
"CMD_TOGGLE_TABBAR": "Toggle Tab Bar",
557+
"CMD_TOGGLE_TABBAR": "File Tab Bar",
558558
"CMD_TOGGLE_PANELS": "Toggle Panels",
559559
"CMD_TOGGLE_PURE_CODE": "No Distractions",
560560
"CMD_TOGGLE_FULLSCREEN": "Fullscreen",

src/view/Pane.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,8 +1225,13 @@ define(function (require, exports, module) {
12251225
* @private
12261226
*/
12271227
Pane.prototype._updateHeaderHeight = function () {
1228-
var paneContentHeight = this.$el.height();
1228+
const $el = this.$el;
1229+
const $tabBar = $el.find(".tab-bar-container");
1230+
let paneContentHeight = $el.height();
12291231

1232+
if($tabBar.length > 0 && $tabBar.is(":visible")) {
1233+
paneContentHeight = paneContentHeight - $tabBar.height();
1234+
}
12301235
// Adjust pane content height for header
12311236
if (MainViewManager.getPaneCount() > 1) {
12321237
this.$header.show();

0 commit comments

Comments
 (0)