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): stop hiding open special tabs when switching back (#12025)

HARRISON4ebf40535ff3
diff --git a/apps/desktop/src/components/layout/EditorGroupTabBar.vue b/apps/desktop/src/components/layout/EditorGroupTabBar.vue
index b3f6d187f9..d849d0fa01 100644
--- a/apps/desktop/src/components/layout/EditorGroupTabBar.vue
+++ b/apps/desktop/src/components/layout/EditorGroupTabBar.vue
@@ -1953,7 +1953,14 @@ watch(
if (container) {
const activeEl = container.querySelector('[data-active-tab="true"]');
if (activeEl) {
- activeEl.scrollIntoView({ behavior: tabScrollBehavior.value, block: "nearest", inline: isVerticalLayout.value ? "nearest" : "center" });
+ // `inline: "nearest"` only scrolls when the tab is actually clipped.
+ // Centering every newly activated tab re-centered ones that were
+ // already fully visible, and because the built-in Settings / Driver
+ // Manager / Plugin Center tabs share this scrollable row, activating
+ // the last regular tab pushed those trailing tabs off the right edge
+ // (#12010). This also matches revealActiveTabAfterLayout and the
+ // special-page watcher below.
+ activeEl.scrollIntoView({ behavior: tabScrollBehavior.value, block: "nearest", inline: "nearest" });
}
}
}
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 357f29d453..c9924e6b55 100644
--- a/apps/desktop/src/components/layout/__tests__/EditorGroupTabBar.behavior.spec.ts
+++ b/apps/desktop/src/components/layout/__tests__/EditorGroupTabBar.behavior.spec.ts
@@ -1,5 +1,5 @@
// @vitest-environment happy-dom
-import { createApp, nextTick, ref } from "vue";
+import { createApp, defineComponent, h, nextTick, ref } from "vue";
import { createPinia, setActivePinia } from "pinia";
import { createI18n } from "vue-i18n";
import { beforeEach, describe, expect, it, vi } from "vitest";
@@ -832,3 +832,58 @@ describe("EditorGroupTabBar behavior", () => {
host.remove();
});
});
+
+describe("active tab reveal scrolling (issue #12010)", () => {
+ // The Settings / Driver Manager / Plugin Center tabs live in the same
+ // scrollable row as regular query tabs. Centering every newly activated tab
+ // re-centered tabs that were already fully visible, which shoved those
+ // trailing special tabs out of the viewport as soon as the user switched back
+ // to the tab before Settings.
+ it("reveals an activated tab without recentering it", async () => {
+ const pinia = createPinia();
+ setActivePinia(pinia);
+ const store = useQueryStore();
+ const settings = useSettingsStore();
+ settings.editorSettings.tabGroupMode = "none";
+ const tabIds = Array.from({ length: 8 }, (_, index) => store.createTab("pg-1", "app", `Query ${index}`, "query"));
+ const mainGroup = store.groups[0]!;
+ const activeTabId = ref(tabIds[0]!);
+ const host = createHost();
+
+ const scrollIntoView = vi.spyOn(HTMLElement.prototype, "scrollIntoView").mockImplementation(() => {});
+ try {
+ const Root = defineComponent({
+ setup() {
+ return () =>
+ h(EditorGroupTabBar, {
+ groupId: mainGroup.id,
+ tabs: store.tabs.slice(),
+ activeTabId: activeTabId.value,
+ });
+ },
+ });
+ const app = createApp(Root);
+ app.use(pinia);
+ app.use(
+ createI18n({
+ legacy: false,
+ locale: "en",
+ messages: { en: { common: { close: "Close" }, contextMenu: { closeTab: "Close" }, sidebar: { locateActiveTab: "Locate" } } },
+ }),
+ );
+ app.mount(host);
+ await settle();
+
+ scrollIntoView.mockClear();
+ activeTabId.value = tabIds[tabIds.length - 2]!;
+ await settle();
+
+ expect(scrollIntoView).toHaveBeenCalledWith(expect.objectContaining({ inline: "nearest" }));
+
+ app.unmount();
+ } finally {
+ scrollIntoView.mockRestore();
+ host.remove();
+ }
+ });
+});