stabilize scroll event wiring

This commit is contained in:
Shantur Rathore
2025-12-05 22:05:27 +00:00
parent 522910ff64
commit 2514fa94b4

View File

@@ -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)
}