diff --git a/packages/nc-gui/components/dashboard/TreeView/TableNode.vue b/packages/nc-gui/components/dashboard/TreeView/TableNode.vue index 309446907d..e4071a7d3c 100644 --- a/packages/nc-gui/components/dashboard/TreeView/TableNode.vue +++ b/packages/nc-gui/components/dashboard/TreeView/TableNode.vue @@ -45,7 +45,7 @@ provide(SidebarTableInj, table) const { setMenuContext, openRenameTableDialog, duplicateTable } = inject(TreeViewInj)! const { loadViews: _loadViews } = useViewsStore() -const { activeView, activeViewTitleOrId } = storeToRefs(useViewsStore()) +const { activeView, activeViewTitleOrId, viewsByTable } = storeToRefs(useViewsStore()) const { isLeftSidebarOpen } = storeToRefs(useSidebarStore()) // todo: temp @@ -138,6 +138,27 @@ watch( const isTableOpened = computed(() => { return openedTableId.value === table.value?.id && (activeView.value?.is_default || !activeViewTitleOrId.value) }) + +let tableTimeout: number + +watch(openedTableId, () => { + if (tableTimeout) { + clearTimeout(tableTimeout) + } + + if (table.value.id !== openedTableId.value && isExpanded.value) { + const views = viewsByTable.value.get(table.value.id!)?.filter((v) => !v.is_default) ?? [] + + if (views.length) return + + tableTimeout = setTimeout(() => { + if (isExpanded.value) { + isExpanded.value = false + } + clearTimeout(tableTimeout) + }, 10000) + } +})