diff --git a/packages/ui/src/components/message-section.tsx b/packages/ui/src/components/message-section.tsx index 76d41941..cdc80c4d 100644 --- a/packages/ui/src/components/message-section.tsx +++ b/packages/ui/src/components/message-section.tsx @@ -215,12 +215,6 @@ export default function MessageSection(props: MessageSectionProps) { scheduleAnchorScroll() } - createEffect(() => { - if (props.registerScrollToBottom) { - props.registerScrollToBottom(() => scrollToBottom(true)) - } - }) - function handleScroll() { if (!containerRef) return if (pendingScrollFrame !== null) { @@ -244,6 +238,12 @@ export default function MessageSection(props: MessageSectionProps) { }) } + createEffect(() => { + if (props.registerScrollToBottom) { + props.registerScrollToBottom(() => scrollToBottom(true)) + } + }) + createEffect(() => { const target = containerRef const loading = props.loading @@ -301,13 +301,6 @@ export default function MessageSection(props: MessageSectionProps) { } updateScrollIndicatorsFromVisibility() }) - - createEffect(() => { - if (autoScroll() && bottomSentinel()) { - scheduleAnchorScroll() - } - }) - createEffect(() => { const container = scrollElement() const topTarget = topSentinel() @@ -337,6 +330,7 @@ export default function MessageSection(props: MessageSectionProps) { }) onCleanup(() => { + if (pendingScrollFrame !== null) { cancelAnimationFrame(pendingScrollFrame) }