I’m building an AI chat interface in WeWeb.
The layout includes:
- A
chat-container
with a fixed height of85vh
. - Inside it, a
message-container
with dynamic height (auto
), which holds all the chat messages (fetched from Xano). - Outside both, I have a
prompt-container
that handles user input and runs a workflow:- It sends the user’s message to Xano,
- Fetches the updated conversation,
- Updates variables, etc.
The challenge:
After fetching new messages, I can’t seem to scroll to the most recent “user message” correctly. I want the scroll behaviour to:
- Bring the “new user message into view” (ideally aligning it with the top of the chat container).
- Show the “AI’s response just below it”.
I’ve been tracking the positions of both chat-container
and message-container
, but haven’t yet found a reliable logic to perform this scroll smoothly.
Is there a way to programmatically scroll the chat-container
so that:
- The latest user message is visible near the top?
The AI message will be automatically shown below anyways.
Any thoughts on the best approach?