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。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(structure): restore horizontal scrollbar after tab switch (#11582)
zipg9262df465a15
diff --git a/apps/desktop/src/components/structure/TableStructureEditor.vue b/apps/desktop/src/components/structure/TableStructureEditor.vueindex c30899077b..efe9bef10f 100644--- a/apps/desktop/src/components/structure/TableStructureEditor.vue+++ b/apps/desktop/src/components/structure/TableStructureEditor.vue@@ -2085,7 +2085,7 @@ function observeStructureHorizontalScroller() {structureHorizontalScrollbarResizeObserver?.disconnect();structureHorizontalScrollbarResizeObserver = null;const tab = activeTab.value;- void nextTick(() => {+ const refresh = () => {if (generation !== structureHorizontalScrollbarObserverGeneration || tab !== activeTab.value) return;const scroller = activeStructureHorizontalScroller();updateStructureHorizontalScrollbar(scroller);@@ -2095,7 +2095,11 @@ function observeStructureHorizontalScroller() {});structureHorizontalScrollbarResizeObserver.observe(scroller);for (const child of Array.from(scroller.children)) structureHorizontalScrollbarResizeObserver.observe(child);- });+ };+ // TabsContent mounts the newly active pane on the tick after the tab change.+ // Defer the measurement one additional tick so returning from a card tab+ // (for example, Triggers) can find the freshly mounted columns scroller.+ void nextTick(() => void nextTick(refresh));}function applyStructureHorizontalScrollbarDrag(clientX: number) {diff --git a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.initialTab.spec.ts b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.initialTab.spec.tsindex 125e034185..0920f0df20 100644--- a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.initialTab.spec.ts+++ b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.initialTab.spec.ts@@ -401,4 +401,41 @@ describe("TableStructureEditor initial tab", () => {expect(root.textContent).toContain("structureEditor.addForeignKey");});++ it.each(["triggers", "ddl", "foreignKeys"])("restores the fields horizontal scrollbar after visiting %s", async (tab) => {+ const scrollWidthDescriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, "scrollWidth");+ const clientWidthDescriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, "clientWidth");+ try {+ Object.defineProperty(HTMLElement.prototype, "scrollWidth", {+ configurable: true,+ get() {+ if (this.classList?.contains("structure-column-virtual-scroller")) return 1200;+ return scrollWidthDescriptor?.get?.call(this) ?? 0;+ },+ });+ Object.defineProperty(HTMLElement.prototype, "clientWidth", {+ configurable: true,+ get() {+ if (this.classList?.contains("structure-column-virtual-scroller")) return 400;+ return clientWidthDescriptor?.get?.call(this) ?? 0;+ },+ });++ const root = await mountStructureEditor();+ await vi.waitFor(() => expect(root.querySelector(".structure-horizontal-scrollbar")).not.toBeNull());++ root.querySelector<HTMLButtonElement>(`[data-tab-trigger="${tab}"]`)!.click();+ await settle();+ expect(root.querySelector(".structure-horizontal-scrollbar")).toBeNull();++ root.querySelector<HTMLButtonElement>('[data-tab-trigger="columns"]')?.click();+ await settle();+ expect(root.querySelector(".structure-horizontal-scrollbar")).not.toBeNull();+ } finally {+ if (scrollWidthDescriptor) Object.defineProperty(HTMLElement.prototype, "scrollWidth", scrollWidthDescriptor);+ else delete (HTMLElement.prototype as { scrollWidth?: number }).scrollWidth;+ if (clientWidthDescriptor) Object.defineProperty(HTMLElement.prototype, "clientWidth", clientWidthDescriptor);+ else delete (HTMLElement.prototype as { clientWidth?: number }).clientWidth;+ }+ });});