reflex-chat icon indicating copy to clipboard operation
reflex-chat copied to clipboard

Autoscrolling

Open ema11412 opened this issue 1 year ago • 3 comments

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

ema11412 avatar Mar 11 '24 05:03 ema11412

I created an issue to make this easier: https://github.com/reflex-dev/reflex/issues/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();")

picklelo avatar Mar 11 '24 22:03 picklelo

Thanks !!

ema11412 avatar Mar 11 '24 23:03 ema11412

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

atsyplikhin avatar May 08 '24 01:05 atsyplikhin