From 5d382f8c4a437db7641bfa35e177370579dbcc73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=85=A7=E5=B3=B0?= <103349961+enootttt@users.noreply.github.com> Date: Sat, 1 Mar 2025 00:54:10 +0800 Subject: [PATCH] fix: Fix the problem that the BubbleList component cannot trigger scrolling (#101) Co-authored-by: lihuifeng --- src/bubble/BubbleList.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bubble/BubbleList.vue b/src/bubble/BubbleList.vue index 0b5feb7..04a3c0a 100644 --- a/src/bubble/BubbleList.vue +++ b/src/bubble/BubbleList.vue @@ -9,7 +9,7 @@ import useDisplayData from './hooks/useDisplayData'; import useListData from './hooks/useListData'; import type { BubbleListProps } from './interface'; import useStyle from './style'; -import { computed, type HTMLAttributes, mergeProps, onWatcherCleanup, ref, unref, useAttrs, watch, watchEffect } from 'vue'; +import { computed, type HTMLAttributes, mergeProps, onWatcherCleanup, ref, unref, useAttrs, watch, watchEffect, nextTick } from 'vue'; import useState from '../_util/hooks/use-state'; import BubbleContextProvider from './context'; @@ -85,10 +85,12 @@ const onInternalScroll = (e: Event) => { watch(updateCount, () => { if (autoScroll && unref(listRef) && unref(scrollReachEnd)) { - unref(listRef).scrollTo({ + nextTick(() => { + unref(listRef).scrollTo({ top: unref(listRef).scrollHeight, }); - } + }) + } }); // Always scroll to bottom when data change