mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-29 00:09:52 +00:00
feat(sidebar): show tooltip on truncated names and enable horizontal scroll (closes #231)
Add a shadcn-vue Tooltip to tree nodes that only activates when the label text is truncated. Enable horizontal scrolling on the sidebar tree container for deeply nested long names.
This commit is contained in:
@@ -247,7 +247,7 @@ function onSearchToggle(node: TreeNode) {
|
||||
</div>
|
||||
<RecycleScroller
|
||||
v-if="flatNodes.length > 0 && useVirtualTree"
|
||||
class="connection-tree-scroller min-h-0 flex-1 overflow-y-auto"
|
||||
class="connection-tree-scroller min-h-0 flex-1 overflow-y-auto overflow-x-auto"
|
||||
:items="flatNodes"
|
||||
:item-size="SIDEBAR_TREE_ROW_HEIGHT"
|
||||
:buffer="SIDEBAR_TREE_SCROLL_BUFFER"
|
||||
@@ -268,7 +268,7 @@ function onSearchToggle(node: TreeNode) {
|
||||
/>
|
||||
</template>
|
||||
</RecycleScroller>
|
||||
<div v-else-if="flatNodes.length > 0" class="min-h-0 flex-1 overflow-y-auto">
|
||||
<div v-else-if="flatNodes.length > 0" class="min-h-0 flex-1 overflow-y-auto overflow-x-auto">
|
||||
<TreeItem
|
||||
v-for="item in flatNodes"
|
||||
:key="item.id"
|
||||
|
||||
@@ -99,8 +99,14 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
|
||||
const { t } = useI18n();
|
||||
const labelRef = ref<HTMLElement>();
|
||||
const isTruncated = computed(() => {
|
||||
const el = labelRef.value;
|
||||
return !!el && el.scrollWidth > el.clientWidth;
|
||||
});
|
||||
const connectionStore = useConnectionStore();
|
||||
const queryStore = useQueryStore();
|
||||
const savedSqlStore = useSavedSqlStore();
|
||||
@@ -1533,7 +1539,12 @@ const isDragging = computed(() => dragState.active && dragState.draggedId === pr
|
||||
@click.stop
|
||||
@vue:mounted="($event: any) => $event.el.focus()"
|
||||
/>
|
||||
<span v-else class="min-w-0 flex-1 truncate">{{ displayLabel(node) }}</span>
|
||||
<Tooltip v-else :disabled="!isTruncated">
|
||||
<TooltipTrigger as-child>
|
||||
<span ref="labelRef" class="min-w-0 flex-1 truncate">{{ displayLabel(node) }}</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right" :side-offset="8">{{ displayLabel(node) }}</TooltipContent>
|
||||
</Tooltip>
|
||||
<span
|
||||
v-if="
|
||||
(node.type === 'group-tables' ||
|
||||
|
||||
Reference in New Issue
Block a user