diff --git a/ui/desktop/src/components/ui/scroll-area.tsx b/ui/desktop/src/components/ui/scroll-area.tsx index 22e19f5d..ed618280 100644 --- a/ui/desktop/src/components/ui/scroll-area.tsx +++ b/ui/desktop/src/components/ui/scroll-area.tsx @@ -17,6 +17,7 @@ const ScrollArea = React.forwardRef( const viewportRef = React.useRef(null); const viewportEndRef = React.useRef(null); const [isFollowing, setIsFollowing] = React.useState(true); + const [isScrolled, setIsScrolled] = React.useState(false); const scrollToBottom = React.useCallback(() => { if (viewportEndRef.current) { @@ -48,6 +49,9 @@ const ScrollArea = React.forwardRef( const scrollBottom = scrollTop + clientHeight; const newIsFollowing = scrollHeight === scrollBottom; + // Check if scrolled from top + setIsScrolled(scrollTop > 0); + // react will internally optimize this to not re-store the same values setIsFollowing(newIsFollowing); }, []); @@ -71,8 +75,15 @@ const ScrollArea = React.forwardRef( +