diff --git a/packages/nc-gui/components/smartsheet/expanded-form/Comments.vue b/packages/nc-gui/components/smartsheet/expanded-form/Comments.vue index d0b9686d7c..e458428b3f 100644 --- a/packages/nc-gui/components/smartsheet/expanded-form/Comments.vue +++ b/packages/nc-gui/components/smartsheet/expanded-form/Comments.vue @@ -186,6 +186,18 @@ function scrollToComment(commentId: string) { } } +function scrollToAudit(auditId?: string) { + if (!auditId) return + + const auditEl = commentsWrapperEl.value?.querySelector(`.nc-audit-item.${auditId}`) + if (auditEl) { + auditEl.scrollIntoView({ + behavior: 'smooth', + block: 'center', + }) + } +} + watch(commentsWrapperEl, () => { setTimeout(() => { nextTick(() => { @@ -261,6 +273,17 @@ function handleResetHoverEffect() { hoveredCommentId.value = null } + +watch( + () => audits.value.length, + (auditCount) => { + nextTick(() => { + setTimeout(() => { + scrollToAudit(audits.value[auditCount - 1]?.id) + }, 100) + }) + }, +) @@ -530,7 +553,7 @@ function handleResetHoverEffect() { -