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): show tooltips only for truncated labels

t8y2f13c46b903d1
diff --git a/apps/desktop/src/components/sidebar/TreeItem.vue b/apps/desktop/src/components/sidebar/TreeItem.vue
index b9c22f32f4..a954cd552e 100644
--- a/apps/desktop/src/components/sidebar/TreeItem.vue
+++ b/apps/desktop/src/components/sidebar/TreeItem.vue
@@ -129,7 +129,10 @@ const labelRef = ref<HTMLElement>();
const rowRef = ref<HTMLElement>();
function isLabelTruncated(): boolean {
const el = labelRef.value;
- return !!el && el.scrollWidth > el.clientWidth;
+ if (!el) return false;
+ const style = window.getComputedStyle(el);
+ if (style.overflowX === "visible" || style.textOverflow !== "ellipsis") return false;
+ return el.scrollWidth - el.clientWidth > 2;
}
const connectionStore = useConnectionStore();
const queryStore = useQueryStore();
@@ -266,8 +269,8 @@ function visibleLabel(node: TreeNode): string {
return displayLabel(node);
}
-function isTooltipDisabled(node: TreeNode): boolean {
- return !isLabelTruncated() && visibleLabel(node) === displayLabel(node);
+function isTooltipDisabled(): boolean {
+ return !isLabelTruncated();
}
async function toggle() {
@@ -2304,13 +2307,7 @@ function treeItemMenuItems(): ContextMenuItem[] {
@keydown.escape.prevent="isRenamingGroup = false"
@click.stop
/>
- <LightTooltip
- v-else
- :text="displayLabel(node)"
- :disabled="isTooltipDisabled(node)"
- side="right"
- :side-offset="8"
- >
+ <LightTooltip v-else :text="displayLabel(node)" :disabled="isTooltipDisabled" side="right" :side-offset="8">
<span ref="labelRef" class="min-w-0 flex-1 truncate">{{ visibleLabel(node) }}</span>
</LightTooltip>
<span
diff --git a/apps/desktop/src/components/ui/LightTooltip.vue b/apps/desktop/src/components/ui/LightTooltip.vue
index e976c6a6cf..ac1c5a676d 100644
--- a/apps/desktop/src/components/ui/LightTooltip.vue
+++ b/apps/desktop/src/components/ui/LightTooltip.vue
@@ -4,7 +4,7 @@ import { computed, onBeforeUnmount, ref, watch } from "vue";
const props = withDefaults(
defineProps<{
text: string;
- disabled?: boolean;
+ disabled?: boolean | (() => boolean);
side?: "top" | "right" | "bottom" | "left";
sideOffset?: number;
delay?: number;
@@ -70,6 +70,10 @@ function isTriggerActive(): boolean {
return el.matches(":hover") || (active instanceof Node && el.contains(active));
}
+function isDisabled(): boolean {
+ return typeof props.disabled === "function" ? props.disabled() : props.disabled;
+}
+
function updatePosition() {
const el = triggerElement();
if (!el) return;
@@ -127,7 +131,7 @@ function removeGlobalListeners() {
}
function open() {
- if (props.disabled || !props.text) return;
+ if (isDisabled() || !props.text) return;
if (!isTriggerActive()) return;
updatePosition();
show.value = true;
@@ -135,7 +139,7 @@ function open() {
}
function scheduleOpen() {
- if (props.disabled || !props.text) return;
+ if (isDisabled() || !props.text) return;
clearTimer();
timer = setTimeout(open, props.delay);
}
@@ -145,7 +149,7 @@ onBeforeUnmount(close);
watch(
() => [props.disabled, props.text] as const,
() => {
- if (props.disabled || !props.text) close();
+ if (isDisabled() || !props.text) close();
else if (show.value) updatePosition();
},
);