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(objects): prevent filter chips from squeezing search input (#13704)

lxk955d13046cc932d
diff --git a/apps/desktop/src/components/objects/ObjectBrowser.vue b/apps/desktop/src/components/objects/ObjectBrowser.vue
index e9cda726ee..663540a241 100644
--- a/apps/desktop/src/components/objects/ObjectBrowser.vue
+++ b/apps/desktop/src/components/objects/ObjectBrowser.vue
@@ -740,7 +740,19 @@ const singleKindFilter = computed<ObjectFilter | null>(() => (!showObjectFilter.
// filter there and drops the database chip. See useToolbarOverflow for the
// tier contract.
const toolbarRef = ref<HTMLElement | null>(null);
-const { tier: toolbarTier } = useToolbarOverflow(toolbarRef, [() => props.database, () => selectedSchema.value, () => needsSchema.value, () => showObjectFilter.value, () => singleKindFilter.value, () => settingsStore.editorSettings.objectBrowserViewMode]);
+const { tier: toolbarTier } = useToolbarOverflow(toolbarRef, [
+ () => props.database,
+ () => selectedSchema.value,
+ () => needsSchema.value,
+ () => showObjectFilter.value,
+ () => singleKindFilter.value,
+ () => objectFilters.value.length,
+ () => objectCounts.value,
+ () => objectFilter.value,
+ () => canCreateSchemaIndex.value,
+ () => oracleInvalidObjectsSupported.value,
+ () => settingsStore.editorSettings.objectBrowserViewMode,
+]);
const showToolbarOverflow = computed(() => toolbarTier.value >= 1);
const showInlineSortAndView = computed(() => toolbarTier.value < 1);
const showInlineCheckboxToggle = computed(() => toolbarTier.value < 1);
@@ -6000,7 +6012,7 @@ function getObjectBrowserMenuItems(item: ObjectBrowserRow): ContextMenuItem[] {
<DatabaseActionsMenu :connection="connection" :database="database" :catalog="catalog" />
</div>
<div class="flex flex-1 items-center gap-2">
- <div class="relative min-w-[6rem] flex-1">
+ <div class="relative min-w-[12rem] flex-1">
<Search class="pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" />
<Input v-model="search" data-object-search-input class="h-7 pl-8 pr-6 text-xs" :placeholder="isMongodb ? t('objects.searchCollections') : t('objects.search')" @keydown="onSearchKeydown" />
<button v-if="search" type="button" class="absolute right-1.5 top-1/2 flex h-4 w-4 -translate-y-1/2 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground" :aria-label="t('common.clear')" @click="clearObjectSearch">
diff --git a/apps/desktop/src/components/objects/__tests__/ObjectBrowser.toolbarSearchWidth.component.spec.ts b/apps/desktop/src/components/objects/__tests__/ObjectBrowser.toolbarSearchWidth.component.spec.ts
new file mode 100644
index 0000000000..0c68ef6f4c
--- /dev/null
+++ b/apps/desktop/src/components/objects/__tests__/ObjectBrowser.toolbarSearchWidth.component.spec.ts
@@ -0,0 +1,125 @@
+// @vitest-environment happy-dom
+import { createApp, defineComponent, h, ref, type App } from "vue";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import ObjectBrowser from "@/components/objects/ObjectBrowser.vue";
+import { invalidateObjectBrowserRowsCache } from "@/lib/table/objectBrowserRowsCache";
+import type { ConnectionConfig } from "@/types/database";
+
+const mocks = vi.hoisted(() => ({
+ listObjects: vi.fn(),
+ listSchemas: vi.fn(),
+ listObjectStatistics: vi.fn(),
+ ensureConnected: vi.fn(),
+}));
+
+vi.mock("@/lib/backend/api", () => ({
+ listObjects: (...args: unknown[]) => mocks.listObjects(...args),
+ listSchemas: (...args: unknown[]) => mocks.listSchemas(...args),
+ listObjectStatistics: (...args: unknown[]) => mocks.listObjectStatistics(...args),
+ mongoListCollections: vi.fn(),
+}));
+vi.mock("@/stores/connectionStore", () => ({
+ useConnectionStore: () => ({
+ getConfig: () => connection,
+ ensureConnected: mocks.ensureConnected,
+ orderByPinnedTreeNodes: (rows: unknown[]) => rows,
+ }),
+}));
+vi.mock("@/stores/queryStore", () => ({ useQueryStore: () => ({}) }));
+vi.mock("@/stores/settingsStore", () => ({
+ useSettingsStore: () => ({
+ editorSettings: {
+ shortcuts: { refreshData: "F5" },
+ objectBrowserViewMode: "list",
+ objectBrowserShowCheckbox: false,
+ sidebarCopyTableNameSeparator: "newline",
+ sidebarCopyTableNameIncludeSchema: false,
+ },
+ }),
+}));
+vi.mock("vue-i18n", () => ({ useI18n: () => ({ t: (key: string) => key, locale: ref("en-US") }) }));
+vi.mock("@/i18n", () => ({ default: { install: () => undefined } }));
+vi.mock("@/composables/useSqlHighlighter", () => ({ useSqlHighlighter: () => ({ highlight: (sql: string) => sql }) }));
+vi.mock("@/composables/useToast", () => ({ useToast: () => ({ toast: vi.fn() }) }));
+vi.mock("vue-virtual-scroller", () => ({
+ RecycleScroller: defineComponent({
+ props: { items: { type: Array, default: () => [] } },
+ setup(props, { slots }) {
+ return () =>
+ h(
+ "div",
+ props.items.map((item) => slots.default?.({ item })),
+ );
+ },
+ }),
+}));
+vi.mock("@/components/ui/searchable-select", () => ({ SearchableSelect: { render: () => null } }));
+vi.mock("@/components/ui/ToolbarOverflowMenu.vue", () => ({ default: { render: () => null } }));
+vi.mock("@/components/ui/CustomContextMenu.vue", () => ({
+ default: defineComponent({
+ setup(_, { slots }) {
+ return () => slots.default?.({ onContextMenu: () => undefined, isOpen: false });
+ },
+ }),
+}));
+vi.mock("@/components/editor/QueryEditor.vue", () => ({ default: { render: () => null } }));
+vi.mock("@/components/editor/DangerConfirmDialog.vue", () => ({ default: { render: () => null } }));
+vi.mock("@/components/objects/ProcedureExecutionDialog.vue", () => ({ default: { render: () => null } }));
+vi.mock("@/components/objects/CustomTypeInfoPanel.vue", () => ({ default: { render: () => null } }));
+vi.mock("@/components/export/XlsxHeaderDialog.vue", () => ({ default: { render: () => null } }));
+
+const connection = {
+ id: "dameng-test",
+ name: "Dameng",
+ db_type: "dameng",
+ database: "DAMENG",
+ driver_profile: null,
+ url_params: null,
+ transport_layers: [],
+} as unknown as ConnectionConfig;
+
+const mountedApps: Array<{ app: App; host: HTMLElement }> = [];
+
+beforeEach(() => {
+ vi.clearAllMocks();
+ mocks.listSchemas.mockResolvedValue([]);
+ mocks.ensureConnected.mockResolvedValue(undefined);
+ mocks.listObjectStatistics.mockResolvedValue([]);
+ invalidateObjectBrowserRowsCache({});
+});
+
+afterEach(() => {
+ for (const { app, host } of mountedApps.splice(0)) {
+ app.unmount();
+ host.remove();
+ }
+ invalidateObjectBrowserRowsCache({});
+});
+
+async function mountBrowser(objects: Array<{ name: string; object_type: string }>) {
+ mocks.listObjects.mockResolvedValue(objects);
+ const host = document.createElement("div");
+ document.body.append(host);
+ const app = createApp({ setup: () => () => h(ObjectBrowser, { connection, database: "DAMENG" }) });
+ mountedApps.push({ app, host });
+ app.mount(host);
+ await vi.waitFor(() => expect(mocks.listObjects).toHaveBeenCalled());
+ return host;
+}
+
+describe("ObjectBrowser toolbar search width (#13581)", () => {
+ it("floors the search input wrapper with min-w-[12rem] so the box is not squished by filter chips", async () => {
+ const host = await mountBrowser([
+ { name: "users", object_type: "TABLE" },
+ { name: "v_users", object_type: "VIEW" },
+ { name: "proc_sync", object_type: "PROCEDURE" },
+ ]);
+
+ const searchInput = host.querySelector<HTMLInputElement>("[data-object-search-input]");
+ expect(searchInput).not.toBeNull();
+ const searchWrapper = searchInput?.closest(".relative");
+ expect(searchWrapper).not.toBeNull();
+ expect(searchWrapper?.className).toContain("min-w-[12rem]");
+ expect(searchWrapper?.className).toContain("flex-1");
+ });
+});
diff --git a/apps/desktop/src/composables/__tests__/useToolbarOverflow.spec.ts b/apps/desktop/src/composables/__tests__/useToolbarOverflow.spec.ts
index 622c4cc1fa..3c9b82a0e1 100644
--- a/apps/desktop/src/composables/__tests__/useToolbarOverflow.spec.ts
+++ b/apps/desktop/src/composables/__tests__/useToolbarOverflow.spec.ts
@@ -98,7 +98,7 @@ describe("useToolbarOverflow", () => {
const { rootRef, tierRef } = createHarness([() => flag.value]);
let contentGrew = false;
- rootRef.value = fakeRow(200, (tier) => (tier >= 1 ? 180 : contentGrew ? 260 : 180), tierRef);
+ rootRef.value = fakeRow(200, (tier) => (tier >= 1 ? 140 : contentGrew ? 260 : 140), tierRef);
await flush();
expect(tierRef.value).toBe(0);
@@ -109,6 +109,13 @@ describe("useToolbarOverflow", () => {
flag.value += 1;
await flush();
expect(tierRef.value).toBe(1);
+
+ // The conditional control disappeared: content shrunk back to where tier 0
+ // fits with ample slack without the pane resizing.
+ contentGrew = false;
+ flag.value += 1;
+ await flush();
+ expect(tierRef.value).toBe(0);
});
it("starts from the full layout when a row re-attaches instead of inheriting a stale tier", async () => {
diff --git a/apps/desktop/src/composables/useToolbarOverflow.ts b/apps/desktop/src/composables/useToolbarOverflow.ts
index d743592de0..1a13daa1ae 100644
--- a/apps/desktop/src/composables/useToolbarOverflow.ts
+++ b/apps/desktop/src/composables/useToolbarOverflow.ts
@@ -60,6 +60,7 @@ export function useToolbarOverflow(rootRef: Ref<HTMLElement | null>, revalidateS
if (revalidateSources.length > 0) {
watch(revalidateSources, () => {
+ condensedAtWidth.value = 0;
void nextTick(measure);
});
}