Forum Academy Marketplace Showcase Pricing Features

Change color of element of repeating group currently selected

Hi!

I’m currently building a messaging app to practice my bubble skills. I want to change the color of the chat that is currently being selected. For this, I have a custom state on the repeating group, as well as one on the group inside the repeating group. Once I click an element, there are 2 events that get called. The first one sets the state of the repeating group as “no”, and the second one sets the state of the element within the RG that has been clicked as “yes”:
Screenshot from 2022-09-26 12-07-33

The group within the repeating group has 2 conditions:
Screenshot from 2022-09-26 12-09-25

Now, here is the problem: if the 2 conditions are listed in that order, the reset doesn’t work, i.e. once the color of an element has been changed, it doesn’t get reset once another element has been selected. On the other hand, if I invert the order of the conditions like so:
Screenshot from 2022-09-26 12-11-59
then, the color never gets changed.

This leads me to conclude that, since both conditions target the same property, then the second one listed takes precedence over the first one. And thus, it seems it is not possible to change a property twice within the same workflow. This would be very easy to do in javascript, but I don’t see how to do it in bubble.

Has anyone encountered a similar problem? Thank you very much!

Hi there, @martinlenweiter… if I understand your post correctly, you should be able to simplify things by using only one custom state (number). When the group/element is clicked, set a custom state’s value to the current cell’s index. Then, put a condition on the group that says when the custom state’s value is the current cell’s index, change the background color of the group.

Hope this helps.

Best…
Mike

Hi Mike! Thanks a lot for your reply, indeed my solution was too complicated and doing it as you suggested did the trick :slight_smile: Only thing is that the custom state had to be bound to the repeating group, not the group wrapping the content of the repeating group. This is because otherwise there would be one custom state per element of the RG, instead of a shared state, which is what we need. Maybe this is what you meant, but in any case it’s working so thank you. Have a nice day!

1 Like

I didn’t specify where to put the custom state, and I usually put them at the page level so they are easy to find. Happy to hear it’s working for you.

ohhhh that’s smart, thanks for the tip!

1 Like

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