fix(desktop): let data header name chips flex to content

This commit is contained in:
Abeautifulsnow authored and GitHub committed 2026-09-03 12:15:56 +08:00
1 parent ef13dc024f
commit 3c4d61339e
3 files changed
+32 -4

No files matched your search

@@ -1904,13 +1904,15 @@ defineExpose({
<template v-else-if="activeTab.mode === 'data'"> <template v-else-if="activeTab.mode === 'data'">
<div class="flex-1 min-h-0 flex flex-col"> <div class="flex-1 min-h-0 flex flex-col">
<div class="h-9 shrink-0 border-b bg-background/80 px-3 flex items-center gap-2 text-xs"> <div class="h-9 shrink-0 border-b bg-background/80 px-3 flex items-center gap-2 text-xs">
<span v-if="activeConnection?.name?.trim()" data-data-header-connection class="inline-flex max-w-48 min-w-0 items-center truncate rounded border border-border bg-muted/30 px-2 py-0.5 text-muted-foreground" :title="activeConnection.name"> <!-- No fixed max-w cap on these chips: they must flex (min-w-0 + truncate)
so long names only clip when the header row itself runs out of space (#7880). -->
<span v-if="activeConnection?.name?.trim()" data-data-header-connection class="inline-flex min-w-0 items-center truncate rounded border border-border bg-muted/30 px-2 py-0.5 text-muted-foreground" :title="activeConnection.name">
{{ activeConnection.name }} {{ activeConnection.name }}
</span> </span>
<span class="inline-flex max-w-48 min-w-0 items-center truncate rounded border border-border bg-muted/50 px-2 py-0.5 font-medium"> <span class="inline-flex min-w-0 items-center truncate rounded border border-border bg-muted/50 px-2 py-0.5 font-medium" :title="activeTab.tableMeta?.tableName || activeTab.title">
{{ activeTab.tableMeta?.tableName || activeTab.title }} {{ activeTab.tableMeta?.tableName || activeTab.title }}
</span> </span>
<span class="inline-flex max-w-56 min-w-0 items-center truncate rounded border border-border bg-muted/30 px-2 py-0.5 text-muted-foreground"> <span class="inline-flex min-w-0 items-center truncate rounded border border-border bg-muted/30 px-2 py-0.5 text-muted-foreground" :title="[activeTab.tableMeta?.schema, databaseDisplayNameForTab(activeTab.connectionId, activeTab.database, t)].filter(Boolean).join('@')">
<template v-if="activeTab.tableMeta?.schema">{{ activeTab.tableMeta.schema }}@</template>{{ databaseDisplayNameForTab(activeTab.connectionId, activeTab.database, t) }} <template v-if="activeTab.tableMeta?.schema">{{ activeTab.tableMeta.schema }}@</template>{{ databaseDisplayNameForTab(activeTab.connectionId, activeTab.database, t) }}
</span> </span>
<span v-if="activeTab.mode === 'data' && activeTab.tableMeta" class="inline-flex shrink-0 items-center rounded border border-border bg-muted/30 px-2 py-0.5 font-medium text-muted-foreground tabular-nums"> {{ activeTab.tableMeta.columns.length }} {{ t("tree.columns") }} </span> <span v-if="activeTab.mode === 'data' && activeTab.tableMeta" class="inline-flex shrink-0 items-center rounded border border-border bg-muted/30 px-2 py-0.5 font-medium text-muted-foreground tabular-nums"> {{ activeTab.tableMeta.columns.length }} {{ t("tree.columns") }} </span>
@@ -0,0 +1,25 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const contentAreaSource = readFileSync(new URL("../ContentArea.vue", import.meta.url), "utf8");
describe("ContentArea data-mode header", () => {
it("lets name chips flex to available width and only truncate when the row overflows", () => {
const headerIndex = contentAreaSource.indexOf("data-data-header-connection");
expect(headerIndex).toBeGreaterThan(-1);
const chipsBlock = contentAreaSource.slice(headerIndex, contentAreaSource.indexOf('class="ml-auto"', headerIndex));
expect(chipsBlock.length).toBeGreaterThan(0);
// Fixed max-w-48/max-w-56 caps clipped table names even with plenty of free
// space in the header row (#7880); chips must rely on min-w-0 + truncate so
// they only clip when the row itself runs out of space.
expect(chipsBlock).not.toContain("max-w-48");
expect(chipsBlock).not.toContain("max-w-56");
expect(chipsBlock).toContain("inline-flex min-w-0 items-center truncate");
});
it("keeps the full table and schema names reachable via title tooltips", () => {
expect(contentAreaSource).toContain(':title="activeTab.tableMeta?.tableName || activeTab.title"');
expect(contentAreaSource).toContain("[activeTab.tableMeta?.schema, databaseDisplayNameForTab(activeTab.connectionId, activeTab.database, t)].filter(Boolean).join('@')");
});
});
+2 -1
View File
@@ -27,5 +27,6 @@ test("data tab header shows the active connection before the table context", ()
assert.ok(connectionIndex >= 0 && connectionIndex < tableIndex); assert.ok(connectionIndex >= 0 && connectionIndex < tableIndex);
assert.match(template, /v-if="activeConnection\?\.name\?\.trim\(\)"/); assert.match(template, /v-if="activeConnection\?\.name\?\.trim\(\)"/);
assert.match(template, /:title="activeConnection\.name"/); assert.match(template, /:title="activeConnection\.name"/);
assert.match(template, /data-data-header-connection class="[^"]*max-w-48[^"]*truncate/); assert.doesNotMatch(template, /data-data-header-connection class="[^"]*(?:max-w-4[89]|max-w-5[0-9])/);
assert.match(template, /data-data-header-connection class="[^"]*min-w-0[^"]*truncate/);
}); });