Skip to content

Conversation

@hugodutka
Copy link
Collaborator

Addresses #9

@hugodutka hugodutka requested a review from BrunoQuaresma May 26, 2025 10:36
@BrunoQuaresma
Copy link
Contributor

I think we can simplify this logic a lot. We can just check if before scrolling on receiving a new message, if the current scroll height is less than the actual height. Makes sense? I think this solution is way to complex. Feel free if you want me to implement that and show you what I'm talking about.

@hugodutka
Copy link
Collaborator Author

@BrunoQuaresma that makes sense. Feel free to take a stab at it, thanks!

Copy link
Contributor

@BrunoQuaresma BrunoQuaresma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is ok for now 👍

@hugodutka
Copy link
Collaborator Author

To add context why we're not pursuing a simpler approach: to determine if we should scroll down we need to check whether a user is scrolled to the bottom BEFORE adding a new message to the virtual DOM, but both useEffect and useLayoutEffect run AFTER. I don't know a React hook that would fit this use case and let us simplify the logic I initially submitted.

@hugodutka hugodutka merged commit 4d05971 into main May 27, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants