chat output remembers scroll position with every scroll, so position is saved when items are deleted as well.
This commit is contained in:
parent
558bed357a
commit
a0d1fcf5a9
1 changed files with 12 additions and 1 deletions
|
|
@ -33,6 +33,17 @@ export default function ChatOutput(props: Props) {
|
|||
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(() => {
|
||||
if (!containerRef.current) return;
|
||||
const container = containerRef.current;
|
||||
|
|
@ -62,7 +73,7 @@ export default function ChatOutput(props: Props) {
|
|||
};
|
||||
|
||||
return (
|
||||
<Box ref={containerRef} style={{
|
||||
<Box ref={containerRef} onScroll={onScroll} style={{
|
||||
overflowY: "scroll",
|
||||
overflowX: "hidden",
|
||||
}}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue