Conditional Statements [tip]

Learned something new today :rofl:, conditional statements are executed from top to bottom, if the bottom one is true, it will override everything on top of it.

Wanted to share this, it might seem silly and obvious for some but I had to learn it the hard way.

Moving the bottom conditional statement to the top, will override the New Seller status and apply the months active.

4 Likes

Thanks! That cool!

1 Like

Thanks, I’ve coded a lot of arguments inside of the conditional statements on a previous project because I didn’t knew this, seems so obvious though :smile:

That’s something I never thought or noticed. Were you just playing around and found it?

Yes, let me show you the result.

Screenshot - 2021-03-26T174028.586

and

Screenshot - 2021-03-26T174054.907

Thats nice! It looks very professional and modern.

Screenshot - 2021-03-26T174209.291

It would be nice if it didn’t override everything else.

Haha Thanks,

I’m building a marketplace template.

Maybe I could be a tester if thats ok with you?

1 Like

Well it actually is nice, because that’s the default behavior as well in traditional coding.

Yeah, I learned about this recently as well. Contacted Bubble support about a bug that my conditional to change the button color on press was not working, although the on hover conditional was.

Support sent it to an engineer after being able to reproduce the issue.

Engineer got in touch and explained the override issue there…so when my on press conditional was at the top and the on hover was on the bottom my on press conditional didn’t work but the on hover did…

when I put the on hover conditional at the top and the on press conditional at the bottom the on press and on hover conditionals worked appropriately.

1 Like

It’s important to note that once a condition evaluates to true, the subsequent conditions are not evaluated, and their corresponding code blocks are skipped. This behavior can be useful for creating cascading or prioritized conditions, where the order of the conditions determines the outcome.

However, it’s also important to design your conditional logic carefully to ensure that the intended behavior is achieved. If you have specific conditions that need to be evaluated independently or need to prioritize certain conditions over others, you may need to adjust the order of your conditions or use additional control structures to handle the logic accordingly.

1 Like

It seems you’ve stumbled upon a little nugget from the past. The reason that we created this topic was for the fact that Bubble once in a time was using the bottom ones to overwrite the latter. :+1: