chat output remembers scroll position with every scroll, so position is saved when items are deleted as well.

This commit is contained in:
Carter 2024-12-06 10:45:37 -06:00
parent 558bed357a
commit a0d1fcf5a9

View file

@ -33,6 +33,17 @@ export default function ChatOutput(props: Props) {
return elem; return elem;
}; };
const onScroll = () => {
if (!containerRef.current) return;
setDisableScrollTo(true)
const container = containerRef.current;
setScrollOffset(container.scrollHeight - container.scrollTop)
}
useEffect(() => {
console.log(scrollOffset)
}, [scrollOffset])
useEffect(() => { useEffect(() => {
if (!containerRef.current) return; if (!containerRef.current) return;
const container = containerRef.current; const container = containerRef.current;
@ -62,7 +73,7 @@ export default function ChatOutput(props: Props) {
}; };
return ( return (
<Box ref={containerRef} style={{ <Box ref={containerRef} onScroll={onScroll} style={{
overflowY: "scroll", overflowY: "scroll",
overflowX: "hidden", overflowX: "hidden",
}}> }}>