diff --git a/packages/nc-gui/components/smartsheet/sidebar/MenuTop.vue b/packages/nc-gui/components/smartsheet/sidebar/MenuTop.vue index 451577c05f..94031e9ecf 100644 --- a/packages/nc-gui/components/smartsheet/sidebar/MenuTop.vue +++ b/packages/nc-gui/components/smartsheet/sidebar/MenuTop.vue @@ -297,13 +297,38 @@ const setIcon = async (icon: string, view: ViewType) => { message.error(await extractSdkResponseErrorMsg(e)) } } + +const scrollViewNode = () => { + const activeViewDom = document.querySelector(`.nc-views-menu [data-view-id="${activeView.value?.id}"]`) as HTMLElement + if (!activeViewDom) return + + if (isElementInvisible(activeViewDom)) { + // Scroll to the view node + activeViewDom?.scrollIntoView({ behavior: 'auto', inline: 'start' }) + } +} + +watch( + () => activeView.value?.id, + () => { + if (!activeView.value?.id) return + + // TODO: Find a better way to scroll to the view node + setTimeout(() => { + scrollViewNode() + }, 800) + }, + { + immediate: true, + }, +)