Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(tabs): let the collapsed tab rail close a tab without switching to it (#12983)

李子凡3488993c1ea5
diff --git a/apps/desktop/src/components/layout/EditorGroupTabBar.vue b/apps/desktop/src/components/layout/EditorGroupTabBar.vue
index 32892472c9..44a40bd3a9 100644
--- a/apps/desktop/src/components/layout/EditorGroupTabBar.vue
+++ b/apps/desktop/src/components/layout/EditorGroupTabBar.vue
@@ -2330,6 +2330,12 @@ watch([() => props.specialPageTabs?.settingsActive, () => props.specialPageTabs?
<button v-if="!isTabBarCollapsed" class="rounded hover:bg-muted-foreground/20 p-0.5 shrink-0" :aria-label="t('contextMenu.closeTab')" :title="t('contextMenu.closeTab')" @pointerdown.stop @click.stop="closeTab(entry.tab)">
<X class="h-3 w-3" />
</button>
+ <!-- The collapsed rail has no row width for the label or the trailing
+ close button (#12942); overlay it so a tab can be closed without
+ expanding the rail and switching to it first. -->
+ <button v-else class="compact-close-tab-button" :aria-label="t('contextMenu.closeTab')" :title="t('contextMenu.closeTab')" @pointerdown.stop @click.stop="closeTab(entry.tab)">
+ <X class="h-2.5 w-2.5" />
+ </button>
</div>
</TooltipTrigger>
<TooltipContent v-if="isConnectionlessPluginTab(entry.tab)" :side="tabTooltipSide" data-plugin-title-tooltip>
diff --git a/apps/desktop/src/components/layout/__tests__/EditorGroupTabBar.behavior.spec.ts b/apps/desktop/src/components/layout/__tests__/EditorGroupTabBar.behavior.spec.ts
index 45793e285e..357f29d453 100644
--- a/apps/desktop/src/components/layout/__tests__/EditorGroupTabBar.behavior.spec.ts
+++ b/apps/desktop/src/components/layout/__tests__/EditorGroupTabBar.behavior.spec.ts
@@ -74,11 +74,13 @@ function mountBar(
specialPageTabs?: { settingsOpen: boolean; settingsActive: boolean; driverStoreOpen: boolean; driverStoreActive: boolean; pluginCenterOpen: boolean; pluginCenterActive: boolean; driverUpdateCount: number },
toolbarActions?: EditorToolbarActions,
onSaveAllTabs?: () => void,
+ extraProps: Record<string, unknown> = {},
): Mounted {
const store = useQueryStore();
const host = createHost();
const app = createApp(EditorGroupTabBar, {
groupId,
+ ...extraProps,
tabs: tabs.map((id) => store.tabs.find((candidate) => candidate.id === id)!),
activeTabId,
"onActivate-tab": onActivateTab,
@@ -805,4 +807,28 @@ describe("EditorGroupTabBar behavior", () => {
app.unmount();
host.remove();
});
+
+ it("offers a close button on every tab in the collapsed vertical rail", async () => {
+ const store = useQueryStore();
+ const settings = useSettingsStore();
+ settings.editorSettings.tabPlacement = "left";
+ const firstId = store.createTab("pg-1", "app", "Query 1", "query");
+ const secondId = store.createTab("pg-1", "app", "Query 2", "query");
+ const { app, host } = mountBar(store.groups[0].id, [firstId, secondId], firstId, pinia, undefined, undefined, undefined, undefined, { tabBarCollapsed: true });
+ await settle();
+
+ // The rail is icon-only, so both a background tab and the active tab must
+ // expose a close affordance without the user switching to it first (#12942).
+ for (const tabId of [firstId, secondId]) {
+ const closeButtons = tabPill(host, tabId).querySelectorAll<HTMLButtonElement>("button[aria-label='Close']");
+ expect(closeButtons, tabId).toHaveLength(1);
+ }
+
+ tabPill(host, secondId).querySelector<HTMLButtonElement>("button[aria-label='Close']")!.click();
+ await settle();
+ expect(store.tabs.some((tab) => tab.id === secondId)).toBe(false);
+
+ app.unmount();
+ host.remove();
+ });
});
diff --git a/apps/desktop/src/components/layout/appTabBar.css b/apps/desktop/src/components/layout/appTabBar.css
index 28356aa015..8f20e7120d 100644
--- a/apps/desktop/src/components/layout/appTabBar.css
+++ b/apps/desktop/src/components/layout/appTabBar.css
@@ -1200,6 +1200,33 @@ html.dbx-legacy-webview .vertical-tab-layout .app-tab-pill:not(.tab-group-tab)[d
box-shadow: 0 0 0 1px var(--background);
}
+/* Icon-only rail: the close affordance overlays the pill on hover/focus so the
+ * rail stays 2.5rem wide (#12942). Bottom-right keeps it clear of the dirty dot. */
+.vertical-tab-layout--collapsed .compact-close-tab-button {
+ position: absolute;
+ right: 0.1rem;
+ bottom: 0.1rem;
+ display: none;
+ align-items: center;
+ justify-content: center;
+ width: 0.95rem;
+ height: 0.95rem;
+ padding: 0;
+ border-radius: 9999px;
+ background: var(--background);
+ color: var(--muted-foreground);
+}
+
+.vertical-tab-layout--collapsed .app-tab-pill:hover .compact-close-tab-button,
+.vertical-tab-layout--collapsed .app-tab-pill:focus-within .compact-close-tab-button {
+ display: inline-flex;
+}
+
+.vertical-tab-layout--collapsed .compact-close-tab-button:hover {
+ background: var(--muted);
+ color: var(--foreground);
+}
+
/* Both portal hosts size from the badges actually rendered, including search
* filtering and multiple editor groups. All bars fill the same host width. */
[data-workspace-tab-navigation],