Skip to content

Commit fb7bfcf

Browse files
author
codeErrorSleep
committed
fix(ui): fix the problem that the tab close button is truncated when hovering
1 parent 9dfce81 commit fb7bfcf

1 file changed

Lines changed: 29 additions & 26 deletions

File tree

src/App.tsx

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,40 +1433,43 @@ export default function App() {
14331433
<TabsTrigger
14341434
value={tab.id}
14351435
className={TAB_TRIGGER_CLASS}
1436+
asChild
14361437
onMouseDown={(e) => {
14371438
if (e.button === 1) {
14381439
e.preventDefault();
14391440
handleCloseTab(tab.id);
14401441
}
14411442
}}
14421443
>
1443-
{tab.type === "table" ? (
1444-
<Table className="w-4 h-4 text-primary" />
1445-
) : (
1446-
<FileCode className="w-4 h-4 text-primary" />
1447-
)}
1448-
<span className="max-w-[120px] flex items-center">
1449-
<span className="truncate">
1450-
{title}
1451-
</span>
1452-
{tab.type === "editor" && tab.isDirty && (
1453-
<span
1454-
className="inline-block w-1.5 h-1.5 rounded-full bg-amber-500 ml-1 shrink-0"
1455-
aria-label={t("app.tab.unsavedChanges")}
1456-
/>
1444+
<div className="relative inline-flex items-center gap-2 min-w-0">
1445+
{tab.type === "table" ? (
1446+
<Table className="w-4 h-4 text-primary" />
1447+
) : (
1448+
<FileCode className="w-4 h-4 text-primary" />
14571449
)}
1458-
</span>
1459-
<button
1460-
type="button"
1461-
aria-label={t("app.tab.closeAria", { title })}
1462-
className="absolute right-1 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 p-1 hover:bg-accent rounded-sm cursor-pointer transition-opacity"
1463-
onClick={(e) => {
1464-
e.stopPropagation();
1465-
handleCloseTab(tab.id);
1466-
}}
1467-
>
1468-
<X className="w-3 h-3 text-muted-foreground" />
1469-
</button>
1450+
<span className="max-w-[120px] flex items-center">
1451+
<span className="truncate">
1452+
{title}
1453+
</span>
1454+
{tab.type === "editor" && tab.isDirty && (
1455+
<span
1456+
className="inline-block w-1.5 h-1.5 rounded-full bg-amber-500 ml-1 shrink-0"
1457+
aria-label={t("app.tab.unsavedChanges")}
1458+
/>
1459+
)}
1460+
</span>
1461+
<button
1462+
type="button"
1463+
aria-label={t("app.tab.closeAria", { title })}
1464+
className="absolute right-1 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 p-1 hover:bg-accent rounded-sm cursor-pointer transition-opacity"
1465+
onClick={(e) => {
1466+
e.stopPropagation();
1467+
handleCloseTab(tab.id);
1468+
}}
1469+
>
1470+
<X className="w-3 h-3 text-muted-foreground" />
1471+
</button>
1472+
</div>
14701473
</TabsTrigger>
14711474
</span>
14721475
</ContextMenuTrigger>

0 commit comments

Comments
 (0)