Repeating group (vertical scrolling) scroll to bottom on open

Hey guys- I built an app with peer to peer chat, but I need the chat window which uses a vertical scrolling repeating group to automatically scroll down when new chats/messages come in.

Right now it auto pulls up to the top, and if new messages are sent it scrolls up a tad.

Thanks!

Try to set the scroll to the list’s :last item when the list is updated.

1 Like

Thanks Scott… is that in the repeating group? or where do I put that info in?

would that setting be within the repeating group?

Got it!

https://bubble.io/reference#Actions.ListShowPrevious.wrap_around is the link for anyone interested, didn;t realize it was an action, and not in the repeating group section.

1 Like

Hi @andrew6, @scottb50,

I have created a peer-to-peer messaging system as well. I am able to get my repeating group of messages to scroll to the ā€œlast itemā€ upon page load (or reload) and when a ā€œsend messageā€ button is clicked from the same page. See image:

But how I can set up an event listener to scroll to the ā€œlast itemā€ when a new message is added to the repeating group of messages remotely (by another user)?

Thanks,
-Tim

Ok, in answer to my own question ā€œBut how I can set up an event listener to scroll to the ā€˜last item’ when a new message is added to the repeating group of messages remotely (by another user)?ā€

This is looking like it works:

  • Create a custom state attached to the repeating group of messages. Custom state should be a number. It will track the ā€˜count’ of messages in the chatbox (aka repeating group of messages)

  • Create a workflow event that fires when page is loaded (Click here to add an event… > General > Page is loaded). It should (1) scroll to ā€˜last item’ of chatbox, then (2) set the custom state described above to number of messages in the chatbox.

  • Create another workflow event (Click here to add an event… > General > Do when condition is true). Edit the ā€œOnly whenā€ setting to fire only when the ā€˜count’ of the chatbox (aka the repeating group’s messages count) is greater than custom state’s count (aka when another message is added to the conversation). There are 2 steps in this workflow event: (1) scroll to ā€˜last item’ of repeating group and (2) set state to (newly updated) ā€˜count’ of messages.

11 Likes

This topic was automatically closed after 70 days. New replies are no longer allowed.