From 0a54aa660b77af2193dc312a8079d08071ecde83 Mon Sep 17 00:00:00 2001 From: Arthur DANJOU Date: Sat, 6 Sep 2025 14:26:11 +0200 Subject: [PATCH] feat: improve scroll behavior based on chat message presence --- app/pages/index.vue | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/pages/index.vue b/app/pages/index.vue index 1ab1f11..8b35c34 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -16,8 +16,21 @@ watch( height, async () => { await nextTick() - if (lastLang.value === locale.value) { - window.scrollTo({ top: parents.value?.scrollHeight, behavior: 'smooth' }) + if (lastLang.value === locale.value && parents.value) { + const children = parents.value.children + if (children.length > 0 && children[children.length - 2]) { + const lastChild = children[children.length - 2] as HTMLElement + window.scrollTo({ + top: lastChild.offsetTop - 10, + behavior: 'smooth', + }) + } + else { + window.scrollTo({ + top: parents.value.scrollHeight, + behavior: 'smooth', + }) + } } lastLang.value = locale.value },