Hi, has anyone noticed this issue? In the new recent Property Editor when I create a Custom State with yes/no type (or Boolean), I cannot set its default value to empty, I’m forced to either select yes or no as default value.
This doesn’t happen in the previous Property editor, in which you can set the Custom state’s default value to nothing or leave it empty.
I know I can switch, however I wanted to use the new property editor and wanted to know how people work around that issue, thanks!
In bubble if a yes/no value is empty bubble evaluates it to no anyway. The new property editor may have been designed to force the default to avoid confusion over empty yes/no evaluating to no
I do wish the behaviour of yes/no were a bit more intuitive- but it is consistent if you know how it works.
I like creating a true Bool Option Set with three values - [true, false, null]
Also add a “yes/no” attribute to it and set it to [yes,no,blank] respectively.
This ends up being more flexible than using the native yes/no - for db fields, datasources, but also for states.
You can set the default value to null, and null's yes/nodoes evaluate to empty.
Basic Example:
Search for Active Users (where active is a yes/no field)
If you use a standard Yes/No state and use the constraint Active=State, even if you set “ignore empty constraints” you’ll only fetch Inactive users or active users, not all at once.
You’d have to duplicate the search in a conditional to fetch all Users - not very maintainable or clean.
If you use the Bool state, and set the constraint as active=Bool State’s yes/no
You’ll get All users when Bool=nulll
You’ll get Active users when Bool=true
You’ll get inactive users when Bool= false
For the dropdown that selects the Active Status filter, you can set another attribute on the option set called ‘display_label’ and set it to All, Active, Inactive.
Thank you for your answer, will definitely test this!
I believe that in the New Property editor you cannot change the default value of a Boolean custom state to empty. Only on the old property editor. It may be a bug.
Your example does seem more flexible and better and bypasses the problem of the new property editor.
Your example is definitely better if you wish to have all 3 choices:
ACTIVE (true)
INACTIVE (false)
ALL (null)
But with the regular Boolean Custom State set to Empty and Yes only (Not No and Yes), you can have:
ACTIVE (yes)
ALL (empty – using ignore empty constraints)
But you still can’t have all 3 choices with just a Boolean Custom State, unless you do more stuff, like you said.
The difference between both methods is: with the option set you can choose true, false and null, while with a boolean state only true and false, or true and null.
To have all 3 states as stated in your example, your way of doing it is better. Also, for the new property editor if the bug isn’t fixed.