fix: replace ResizeObserver with useEffect for auto-scroll in LeadThoughtsGroup
ResizeObserver stops firing once scroll container reaches maxHeight, breaking auto-scroll for long-running live thought groups. Use useEffect on chronologicalThoughts dependency instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
baabae0594
commit
795e1248aa
1 changed files with 4 additions and 9 deletions
|
|
@ -258,17 +258,12 @@ export const LeadThoughtsGroupRow = ({
|
||||||
return () => observer.disconnect();
|
return () => observer.disconnect();
|
||||||
}, [onVisible, thoughts]);
|
}, [onVisible, thoughts]);
|
||||||
|
|
||||||
// Auto-scroll via ResizeObserver — fires after CSS animations expand content
|
// Auto-scroll when new thoughts arrive
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const el = scrollRef.current;
|
const el = scrollRef.current;
|
||||||
if (!el) return;
|
if (!el || isUserScrolledUpRef.current) return;
|
||||||
const observer = new ResizeObserver(() => {
|
el.scrollTop = el.scrollHeight;
|
||||||
if (isUserScrolledUpRef.current) return;
|
}, [chronologicalThoughts]);
|
||||||
el.scrollTop = el.scrollHeight;
|
|
||||||
});
|
|
||||||
observer.observe(el);
|
|
||||||
return () => observer.disconnect();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleScroll = useCallback(() => {
|
const handleScroll = useCallback(() => {
|
||||||
const el = scrollRef.current;
|
const el = scrollRef.current;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue