Skip to content

Commit ad9c7a9

Browse files
committed
Remove ScrollBox re-rendering on child height change effect
1 parent a94d155 commit ad9c7a9

File tree

1 file changed

+0
-30
lines changed

1 file changed

+0
-30
lines changed

cli/src/hooks/use-scroll-management.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -148,36 +148,6 @@ export const useChatScrollbox = (
148148
}
149149
}, [cancelAnimation])
150150

151-
const previousHeightRef = useRef<number>(0)
152-
// Monitor scrollbox height and trigger re-render when it changes significantly
153-
useEffect(() => {
154-
const scrollbox = scrollRef.current
155-
if (!scrollbox) return
156-
157-
const heightThreshold = 10 // Re-render if height changes by more than this
158-
159-
const checkHeightChange = () => {
160-
const currentHeight = scrollbox.scrollHeight
161-
const previousHeight = previousHeightRef.current
162-
const heightDiff = Math.abs(currentHeight - previousHeight)
163-
164-
if (heightDiff > heightThreshold) {
165-
logger.info(
166-
{ currentHeight, previousHeight, heightDiff },
167-
`Re-rendering ScrollBox due to height change of ${heightDiff}`,
168-
)
169-
previousHeightRef.current = currentHeight
170-
scrollbox.requestRender()
171-
} else {
172-
previousHeightRef.current = currentHeight
173-
}
174-
}
175-
176-
const timeoutId = setTimeout(checkHeightChange, 0)
177-
178-
return () => clearTimeout(timeoutId)
179-
})
180-
181151
return {
182152
scrollToLatest,
183153
scrollboxProps: {},

0 commit comments

Comments
 (0)