-
Notifications
You must be signed in to change notification settings - Fork 290
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
Chat component's auto-scroll not working when used with a web component #1121
Comments
Hmm, that's a weird issue. Not immediately clear to me why the scroll command would not be able to find the component when you add a web component. Thanks for the repro code. I'll try to test it out some time this week. |
Ok. I took a look. I was able to repro the issue from your repo. And then repro'd against head. I don't know the exact reason why adding a web component causes the scroll to to fail. My guess is that it maybe it slows rendering down a bit. In the mel.chat case, we have a hidden div that appears. Here's the code in question (https://github.com/google/mesop/blob/main/mesop/web/src/shell/shell.ts). To fix the issue at least for mel.chat, I added 500 ms delay in the timeout. That seemed to work. I think at 400ms, it also worked. But 300ms did not. However, I'm on the fence for if we should add the 500ms delay here since for use cases where the element already exists and is visible, the delay is likely not needed. And in some cases, perhaps, the delay could be larger.
For a short term fix, you can also make a copy of mel.chat (https://github.com/google/mesop/blob/main/mesop/labs/chat.py). You can save the file as chat.py and then import it. You can then basically use it the same as mel.chat. Some where in that file, you'll see code like this:
Basically, you can manually add a sleep here like this:
I think I will probably update mel.chat with the custom sleep for a short term fix. |
@richard-to Thanks! The workaround fixed the issue. |
I'm wondering if we can use afterRender to more reliably run the scroll command: afterRender |
Describe the bug
The auto-scroll from the chat component is not working when a web component is added after the chat component.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
After user enters the message, the auto-scroll behaviour should take place.
Screenshots
Desktop System Info
Additional context
The text was updated successfully, but these errors were encountered: