-
Notifications
You must be signed in to change notification settings - Fork 59.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify [UI/UX] [Chat] [Front End] scrollDomToBottom #4021
Conversation
- [+] refactor(chat.tsx): improve smooth scrolling behavior in useScrollToBottom function
@H0llyW00dzZ is attempting to deploy a commit to the NextChat Team on Vercel. A member of the Team first needs to authorize it. |
Your build has completed! |
Note This so smoothly unlike stupid |
This works well, also allows scrolling back up while response is still streaming. However, sometimes it won't keep scrolling down even if nothing was touched and the answer is still streaming in. |
haven't improve yet, its very complexity because of codebase too large and other, Also I am still figure out to made it better |
anyway its difficult to maintain especially for improve, because of stupid complexity that I don't fucking understand about frontend especially react,typescript unlike backend written in go |
If found it's the actual smooth scrolling that breaks this. If you make it immediately update the scrolling position it keeps scrolling down, unless the user scrolls back up. See 4b3c41a for an example |
wait I think I know how to improve it |
this a better one but not smoothly, can scroll up to 999999+ messages combine with this commit 4b3c41a + using react custom hook |
the custom hook: // Custom hook for debouncing a function
function useDebouncedEffect(effect: () => void, deps: any[], delay: number) {
// Include `effect` in the dependency array for `useCallback`
const callback = useCallback(effect, [effect, ...deps]);
useEffect(() => {
const handler = debounce(callback, delay);
handler();
// Cleanup function to cancel the debounced call if the component unmounts
return () => handler.cancel();
}, [callback, delay]); // `callback` already includes `effect` in its dependencies, so no need to add it here again.
} |
Issues: