diff --git a/packages/nc-gui/components/dashboard/TreeView.vue b/packages/nc-gui/components/dashboard/TreeView.vue index 02d0446dc4..10a5d9fbff 100644 --- a/packages/nc-gui/components/dashboard/TreeView.vue +++ b/packages/nc-gui/components/dashboard/TreeView.vue @@ -273,10 +273,23 @@ useEventListener(document, 'keydown', async (e: KeyboardEvent) => { } }) -onMounted(() => { - if (bases.value.filter((el) => el.enabled)[0]?.id) - activeKey.value.push(`collapse-${bases.value.filter((el) => el.enabled)[0].id}`) -}) +watch( + activeTable, + (value, oldValue) => { + if (value) { + if (value !== oldValue) { + const fndTable = tables.value.find((el) => el.id === value) + if (fndTable) { + activeKey.value = [`collapse-${fndTable.base_id}`] + } + } + } else { + if (bases.value.filter((el) => el.enabled)[0]?.id) + activeKey.value = [`collapse-${bases.value.filter((el) => el.enabled)[0].id}`] + } + }, + { immediate: true }, +)