Hello,
I’m having trouble managing the selection and deselection of elements in my Bubble app.
Specifically:
-
In a Repeating Group, I have a “Like” button under each message.
-
I set up a workflow so that when I click the button, the icon changes color to indicate that the element is liked.
-
However, when I try to click it again to remove the like and reset the button to its original state, it doesn’t work.
-
I’ve included a screenshot at the bottom showing the exact workflow configuration.
Additional notes:
-
I have several other similar issues with selection/deselection, not necessarily with icons, but the workflow configuration is often the same.
-
I suspect the problem is related to the way I’ve set up the selection/deselection logic, rather than a bug with a specific button.
If anyone has encountered this kind of issue or has suggestions on why deselection might not be working, I would greatly appreciate your advice.
Thank you in advance for your help!
The issue you’re having is pretty common with toggle-style workflows in Bubble. From what you’re describing, it sounds like you’ve set up a workflow that changes the icon when clicked, but you don’t have a proper condition to reverse it back.
The typical mistake is setting up just one workflow action that changes the state or appearance when clicked, but not accounting for what happens when it’s already in the “liked” state. You need to create conditional logic that checks the current state first, then acts accordingly.
Without seeing your exact workflow setup, here’s generally what you need: you should either use a custom state to track whether something is liked or not, or check against your database if you’re storing likes there. Your workflow should have two paths - one that runs when the item is NOT liked (adds the like and changes the icon), and another that runs when it IS already liked (removes the like and resets the icon).
The way to do this is either with conditional workflow actions using “Only when” conditions, or by using separate workflows with different triggers. For example, your click event could check “Only when custom state is_liked is no” for the like action, and have another action in the same workflow with “Only when custom state is_liked is yes” for the unlike action.
If you can share a screenshot of your current workflow setup, I can tell you exactly what needs to be adjusted to get the deselection working properly.
1 Like
Thank you very much for your help.
I’m sharing here the workflow of the like button as well as the conditional settings.
At the moment, I’m not using any custom state. I did try using one a long time ago, but unfortunately it didn’t work either, so I moved away from that approach.
Just to clarify the issue:
In preview mode, I’m able to like a post and the button/icon correctly changes color. However, I’m unable to deselect it,the icon never goes back to its original state.
Additionally, I have a repeating group that displays all liked posts using a “Do a search for Posts”. The field liked_by is a list of Users. I’m not sure if this detail is relevant, but I thought it might help.
Thanks again for your time and support.
It doesn’t work because you have the remove and add actions in the same workflow, and that ends up not working.
Imagine that when the workflow runs, it runs the first step, then it checks that that Post has already been liked by that user, so it removes it. But then it gets to the second step, and it checks that that Post hasn’t been liked by that user, because we removed it in the previous step, so it adds it again.
What you need to do is have two workflows, and the condition on the icon:
Workflow that adds:
Workflow that removes: