Skip to content
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

Autoscrolling #31

Open
ema11412 opened this issue Mar 11, 2024 · 3 comments
Open

Autoscrolling #31

ema11412 opened this issue Mar 11, 2024 · 3 comments

Comments

@ema11412
Copy link

How to autoscroll the chat when bringing the chatgpt answer and that when entering each chat it always automatically scrolls down to the end?

@picklelo
Copy link
Contributor

I created an issue to make this easier: reflex-dev/reflex#2834

I'll post the updated code onto the repo here soon, but my solution is to add id tags to each message, and then add this line in the process function:

    # Set the processing flag.
    chat.processing = True

    # TODO: We need an `rx.scroll_to` function to simplify this.
    yield rx.call_script(f"document.getElementById('message-{len(chat.messages) - 1}').scrollIntoView();")

@ema11412
Copy link
Author

Thanks !!

@atsyplikhin
Copy link

I am struggling to make this work. Please advise how to update the code in this repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants