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(sidebar): respect horizontal scrolling and constrain connection notes

zipg863063fd1226
diff --git a/apps/desktop/src/components/sidebar/TreeItem.vue b/apps/desktop/src/components/sidebar/TreeItem.vue
index aeb22048ad..5d2a80d284 100644
--- a/apps/desktop/src/components/sidebar/TreeItem.vue
+++ b/apps/desktop/src/components/sidebar/TreeItem.vue
@@ -828,7 +828,7 @@ function measureTrailingCommentLayout() {
trailingCommentMaxWidth.value = 0;
return;
}
- trailingCommentMaxWidth.value = settingsStore.editorSettings.sidebarAllowHorizontalScroll ? sidebarRightCommentMaxWidthPx : trailingCommentAvailableWidth(container.clientWidth, leading.scrollWidth);
+ trailingCommentMaxWidth.value = usesFullWidthLabel.value ? sidebarRightCommentMaxWidthPx : trailingCommentAvailableWidth(container.clientWidth, leading.scrollWidth);
}
function scheduleTrailingCommentMeasure() {
@@ -873,7 +873,7 @@ function formattedObjectStorage(): string {
const alignedCommentLabelWidth = computed(() => (settingsStore.editorSettings.sidebarObjectInfoMode === "comment-aligned" && activeNode.value.type !== "connection" ? props.commentLabelWidth : undefined));
function alignedCommentLeadingStyle(): { width: string } | { maxWidth: string } | undefined {
- if (!settingsStore.editorSettings.sidebarAllowHorizontalScroll && settingsStore.editorSettings.sidebarObjectInfoMode === "comment-and-size" && trailingComment.value) {
+ if (!usesFullWidthLabel.value && settingsStore.editorSettings.sidebarObjectInfoMode === "comment-and-size" && trailingComment.value) {
// Reserve the inline comment's margin so a long name cannot push into the size column.
return { maxWidth: "max(0px, calc(100% - 1rem))" };
}
@@ -889,6 +889,7 @@ const usesFullWidthLabel = computed(() => usesFullWidthTreeLabel(activeNode.valu
const isCompactSidebar = computed(() => settingsStore.editorSettings.sidebarDensity === "compact");
+const isConnectionRow = computed(() => activeNode.value.type === "connection" || activeNode.value.type === "connection-group");
const rowWidthClass = computed(() => (usesFullWidthLabel.value ? "w-max min-w-full" : "w-full min-w-0 tree-row-viewport"));
const labelWidthClass = computed(() => {
@@ -1658,7 +1659,17 @@ function onKeydown(event: KeyboardEvent) {
>
<div
ref="trailingCommentLeadingRef"
- :class="trailingComment ? (usesFullWidthLabel ? 'flex min-w-0 shrink-0 items-center gap-2' : 'flex max-w-full min-w-0 shrink-0 items-center gap-2') : formattedObjectStorage() ? 'flex min-w-0 flex-1 items-center gap-2' : 'contents'"
+ :class="
+ trailingComment
+ ? usesFullWidthLabel
+ ? 'flex min-w-0 shrink-0 items-center gap-2'
+ : isConnectionRow
+ ? 'flex max-w-full min-w-0 shrink items-center gap-2'
+ : 'flex max-w-full min-w-0 shrink-0 items-center gap-2'
+ : formattedObjectStorage()
+ ? 'flex min-w-0 flex-1 items-center gap-2'
+ : 'contents'
+ "
:style="alignedCommentLeadingStyle()"
>
<input
@@ -1677,7 +1688,7 @@ function onKeydown(event: KeyboardEvent) {
:class="[
labelWidthClass,
{
- 'flex-1': node.type === 'connection' && !trailingComment,
+ 'flex-1': isConnectionRow && !trailingComment,
'tree-connection-label': node.type === 'connection' || node.type === 'connection-group',
'tree-object-label': node.type !== 'connection' && node.type !== 'connection-group',
'font-semibold': isLoginUserNode(),
diff --git a/apps/desktop/src/lib/__tests__/sidebar/sidebarTreeItemLayout.spec.ts b/apps/desktop/src/lib/__tests__/sidebar/sidebarTreeItemLayout.spec.ts
index 339fb2285e..4685b2e125 100644
--- a/apps/desktop/src/lib/__tests__/sidebar/sidebarTreeItemLayout.spec.ts
+++ b/apps/desktop/src/lib/__tests__/sidebar/sidebarTreeItemLayout.spec.ts
@@ -21,7 +21,7 @@ describe("sidebar tree item layout", () => {
});
it("supports ordinary nodes but excludes controls and group headings", () => {
- for (const type of ["database", "schema", "column", "index", "connection", "mongo-db", "elasticsearch-index"] as const) {
+ for (const type of ["database", "schema", "column", "index", "connection", "connection-group", "mongo-db", "elasticsearch-index"] as const) {
expect(usesFullWidthTreeLabel(type, true, true)).toBe(true);
expect(usesFullWidthTreeLabel(type, false)).toBe(false);
}
diff --git a/apps/desktop/src/lib/sidebar/sidebarTreeItemLayout.ts b/apps/desktop/src/lib/sidebar/sidebarTreeItemLayout.ts
index 098a3c8b32..a57e246f8d 100644
--- a/apps/desktop/src/lib/sidebar/sidebarTreeItemLayout.ts
+++ b/apps/desktop/src/lib/sidebar/sidebarTreeItemLayout.ts
@@ -44,9 +44,8 @@ const leafTypes: Set<TreeNodeType> = new Set([
"datafile",
]);
-// Search controls are laid out against the viewport. Every other visible tree
-// row may contain a user supplied name and must be able to contribute to the
-// horizontal scroll width when that setting is enabled.
+// Controls stay viewport-sized. Names, including connections and groups, may
+// contribute their natural width when the user allows horizontal scrolling.
const nonNaturalWidthTypes: Set<TreeNodeType> = new Set(["table-search-control", "load-more"]);
const emptyContainerTypes: Set<TreeNodeType> = new Set(["saved-sql-root", "saved-sql-folder", "type"]);