Skip to content

Commit e62fa8d

Browse files
authored
fix: table sidebar display with many databases (#593)
fix: table sidebar display with many tables
1 parent 3ae6636 commit e62fa8d

1 file changed

Lines changed: 22 additions & 12 deletions

File tree

src/views/dashboard/modules/table-manager.vue

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,12 @@ a-card.table-manager(:bordered="false")
2424
svg.icon.icon-color
2525
use(href="#search")
2626
a-tooltip(
27-
:content="$t('dashboard.hideSidebar')"
28-
position="tr"
2927
v-model:popup-visible="tooltipVisible"
28+
position="tr"
3029
mini
30+
:content="$t('dashboard.hideSidebar')"
3131
)
32-
a-button(
33-
type="secondary"
34-
size="mini"
35-
@click="toggleSidebar"
36-
)
32+
a-button(type="secondary" size="mini" @click="toggleSidebar")
3733
template(#icon)
3834
svg.icon.icon-color.rotate-270(:class="{ 'rotate-180': hideSidebar }")
3935
use(href="#collapse")
@@ -58,12 +54,12 @@ a-card.table-manager(:bordered="false")
5854
v-model:expanded-keys="expandedKeys"
5955
size="small"
6056
action-on-node-click="expand"
61-
:ref="(el: refItem) => setRefMap(el, database)"
57+
:ref="(el) => setRefMap(el, database)"
6258
:block-node="true"
6359
:data="tablesTreeData"
6460
:load-more="loadMore"
6561
:animation="false"
66-
:virtual-list-props="{threshold:100, buffer:20, height: `calc(100vh - ${collapseHeadersHeight}px - var(--tables-header-height) - var(--footer-height))` }"
62+
:virtual-list-props="{ threshold: 100, buffer: 20, height: virtualListHeight }"
6763
)
6864
template(#icon="node")
6965
a-tooltip(v-if="node.node.iconType" :content="node.node.iconType")
@@ -79,7 +75,8 @@ a-card.table-manager(:bordered="false")
7975
:database="database"
8076
:expandedKeys="expandedKeys"
8177
:expandedTablesTree="expandedTablesTree"
82-
@expandChildren="expandChildren")
78+
@expandChildren="expandChildren"
79+
)
8380
.tree-data(v-else-if="nodeData.dataType")
8481
.data-title.columns
8582
| {{ nodeData.title }}
@@ -92,7 +89,8 @@ a-card.table-manager(:bordered="false")
9289
:database="database"
9390
:expandedKeys="expandedKeys"
9491
:expandedTablesTree="expandedTablesTree"
95-
@expandChildren="expandChildren")
92+
@expandChildren="expandChildren"
93+
)
9694
.detail-row(v-else)
9795
.count-and-time(v-if="nodeData.title === 'rowAndTime'")
9896
a-space(:size="4")
@@ -161,6 +159,8 @@ a-card.table-manager(:bordered="false")
161159
)
162160
163161
const collapseHeadersHeight = computed(() => props.databaseList.length * 36)
162+
const TABLE_NODE_HEIGHT = 32
163+
const MIN_VIRTUAL_LIST_HEIGHT = 200
164164
165165
const expandedKeys = ref<number[]>([])
166166
const tooltipVisible = ref(false)
@@ -206,6 +206,14 @@ a-card.table-manager(:bordered="false")
206206
)
207207
})
208208
209+
const virtualListHeight = computed(() => {
210+
const itemsCount = tablesTreeData.value.length || 0
211+
const actualHeight = Math.max(itemsCount * TABLE_NODE_HEIGHT, MIN_VIRTUAL_LIST_HEIGHT)
212+
const maxHeight = `calc((100vh - var(--tables-header-height) - var(--footer-height)) / 2)`
213+
// Use the smaller between actual content height and the max allowed height
214+
return `min(${actualHeight}px, ${maxHeight})`
215+
})
216+
209217
const expandChildren = (event: Event, nodeData: TableTreeParent, type: 'details' | 'columns') => {
210218
expandedKeys.value.push(nodeData.key)
211219
nodeData.children = nodeData[type]
@@ -566,7 +574,6 @@ a-card.table-manager(:bordered="false")
566574
align-items: center;
567575
justify-content: center;
568576
flex-direction: column;
569-
height: 50vh;
570577
}
571578
572579
.arco-dropdown-open {
@@ -627,6 +634,9 @@ a-card.table-manager(:bordered="false")
627634
}
628635
629636
.arco-collapse.arco-collapse-borderless.databases {
637+
max-height: calc(100vh - var(--tables-header-height) - var(--footer-height));
638+
overflow-y: auto;
639+
overscroll-behavior: contain;
630640
border-radius: 0;
631641
632642
> .arco-collapse-item-active {

0 commit comments

Comments
 (0)