Skip to content

Commit 16a51a1

Browse files
committed
fix: scroll to active tab not working for placeholder tabs
1 parent edb88ad commit 16a51a1

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

src/extensionsIntegrated/TabBar/overflow.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ define(function (require, exports, module) {
7575
name: $tab.find('.tab-name').text(),
7676
isActive: $tab.hasClass('active'),
7777
isDirty: $tab.hasClass('dirty'),
78+
isPlaceholder: $tab.hasClass('placeholder'),
7879
$icon: $tab.find('.tab-icon').clone()
7980
};
8081

@@ -148,17 +149,22 @@ define(function (require, exports, module) {
148149
<i class="fa-solid fa-times"></i>
149150
</span>`;
150151

152+
// add placeholder class to style it differently
153+
const placeholderClass = item.isPlaceholder ? ' placeholder-name' : '';
154+
151155
// return html for this item
152156
return {
153157
html:
154-
`<div class="dropdown-tab-item" data-tab-path="${item.path}">
155-
<div class="tab-info-container">
156-
${dirtyHtml}
157-
<span class="tab-icon-container">${iconHtml}</span>
158-
<span class="tab-name-container">${item.name}</span>
159-
</div>
160-
${closeIconHtml}
161-
</div>`,
158+
`<div class="dropdown-tab-item${item.isPlaceholder
159+
? ' placeholder-item' : ''
160+
}" data-tab-path="${item.path}">
161+
<div class="tab-info-container">
162+
${dirtyHtml}
163+
<span class="tab-icon-container">${iconHtml}</span>
164+
<span class="tab-name-container${placeholderClass}">${item.name}</span>
165+
</div>
166+
${closeIconHtml}
167+
</div>`,
162168
enabled: true
163169
};
164170
});
@@ -223,6 +229,14 @@ define(function (require, exports, module) {
223229
// Set the active pane and open the file
224230
MainViewManager.setActivePaneId(paneId);
225231
CommandManager.execute(Commands.FILE_OPEN, { fullPath: filePath });
232+
233+
// get the tab bar element based on paneId and scroll to the active tab
234+
// we use setTimeout to ensure that the DOM has updated after the file open command
235+
setTimeout(function () {
236+
const $tabBarElement = paneId === "first-pane" ?
237+
$("#phoenix-tab-bar") : $("#phoenix-tab-bar-2");
238+
scrollToActiveTab($tabBarElement);
239+
}, 100);
226240
}
227241
});
228242

src/styles/Extn-TabBar.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,4 +403,9 @@
403403

404404
.empty-pane-drop-target {
405405
border: 2px dashed #6db6ff !important;
406+
}
407+
408+
.dropdown-tab-item.placeholder-item .tab-name-container,
409+
.tab-name-container.placeholder-name {
410+
font-style: italic;
406411
}

0 commit comments

Comments
 (0)