Skip to content

Commit 0275221

Browse files
committed
feat: enhance tab functionality with middle-click close and visual distinction for temporary previews
1 parent 87ae80c commit 0275221

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

packages/ui/lib/components/PanelTabs/PanelTabs.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ export const PanelTabs = memo(function PanelTabs({
4444
() =>
4545
tabs.map((tab) => {
4646
const isPreview = tab.type === "preview";
47-
const isTemp = isPreview && tab.isTemp && !tab.dirty;
47+
// Temporary preview tabs are visually distinct (italic) until they are
48+
// explicitly pinned (double-click) or promoted by edits.
49+
const isTemp = isPreview && tab.isTemp;
4850
return {
4951
id: tab.id,
5052
label: tabLabel(tab),
@@ -63,7 +65,7 @@ export const PanelTabs = memo(function PanelTabs({
6365
onDoubleClickItem={onDoubleClickTab}
6466
onCloseItem={onCloseTab}
6567
onReorderItems={onReorderTabs}
66-
getItemClassName={(item) => (item.temp ? panelTabsStyles.temp : undefined)}
68+
getItemClassName={(item) => (item.temp ? "temp" : undefined)}
6769
rightSlot={
6870
<ActionBar>
6971
<NestedPopoverMenu

packages/ui/lib/components/Tabs/Tabs.module.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@
9393
min-width: 48px;
9494
}
9595

96+
.panelTab.temp .label {
97+
font-style: italic;
98+
}
99+
96100
.panelTab:hover {
97101
color: var(--fg);
98102
background: var(--entry-hover, rgba(255, 255, 255, 0.06));

packages/ui/lib/components/Tabs/Tabs.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ export const Tabs = memo(function Tabs<T extends TabsItem>({
176176
event.preventDefault();
177177
onDoubleClickItem(item.id);
178178
} : undefined}
179+
onAuxClick={onCloseItem ? (event) => {
180+
// Middle-click closes tabs (common desktop tab UX).
181+
if (event.button !== 1) return;
182+
event.preventDefault();
183+
onCloseItem(item.id);
184+
} : undefined}
179185
title={item.title}
180186
draggable={Boolean(onReorderItems)}
181187
onDragStart={onReorderItems ? (event) => handleDragStart(event, index) : undefined}

0 commit comments

Comments
 (0)