fix: throttle scroll to bottom

This commit is contained in:
Daniel Avila 2023-03-19 11:45:03 -04:00
parent 4ce60537ca
commit 4cd0ff2682
2 changed files with 4 additions and 3 deletions

View file

@ -49,7 +49,6 @@ const inLineWrap = (parts) => {
export default function TextWrapper({ text, generateCursor }) {
let embedTest = false;
let result = null;
console.log('text wrapper', text)
// to match unenclosed code blocks
if (text.match(/```/g)?.length === 1) {

View file

@ -1,5 +1,6 @@
import React, { useEffect, useState, useRef, useCallback } from 'react';
import Spinner from '../svg/Spinner';
import { throttle } from 'lodash';
import { CSSTransition } from 'react-transition-group';
import ScrollToBottom from './ScrollToBottom';
import MultiMessage from './MultiMessage';
@ -34,10 +35,11 @@ export default function Messages({ messages, messageTree }) {
};
}, [messages]);
const scrollToBottom = useCallback(() => {
const scrollToBottom = useCallback(throttle(() => {
console.log('scrollToBottom');
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
setShowScrollButton(false);
}, [messagesEndRef]);
}, 750), [messagesEndRef]);
const handleScroll = () => {
const { scrollTop, scrollHeight, clientHeight } = scrollableRef.current;