Dropdown representing 00 incorrectly

@Xec as @JohnMark suggested you can use the Air Static Dropdown labels plugin to address this 00 issue.

I’ve actually looked into this 00 issue and its a very beautiful problem :grinning:

So bubble try to be smart and automatically returns the the dropdown value as numbers if all the entered choices are numbers.
I don’t know their code but they’re using some function to check if all the options are numbers. For example something like !dropDownOptionsList.some(isNaN). And if this is true they return the dropdown value as a number.

Fortunately or unfortunately 00 is treated as a number (javascript treats any 0 prefix digits of a number as a number, e.g. 00023 is a number). So if you do something like
![00,15,30,45].some(isNaN)
it will return true saying all the values in the array are numbers and therefore makes the dropdown return value as a number. This unfortunately formats 00 as 0.

But assuming one of the options was text, then the dropdown will be considered as returning text. This is why someone said in this post that putting a double quote around one of the values kind of fix it.
The issue with that workaround is that the option with the double quotes will be returned with the quotes so its not really a good fix.

So this is not really a bug as it is by design just that in this particular case the resulting behaviour is unintended.

So obviously the solution here will be a way to tell bubble that hey treat these values as text and not numbers even though i know i’ve entered numbers.

While we await bubble to one day add such an option, here is how you can use the Air Static Dropdown labels to solve your issue.

  1. Add the AirDropdownLabels alement and enter your time values with the 00 image
  2. Enter the same values in your original dropdown. Here it doesn’t matter whether you enter 0 or 00 as the dropdown will still return 0.
  3. If you want to store the value as numbers then you don’t need to do anything more. And you can always compare 0 to 00. In javascript 0 is equal to 00.
  4. But if you want to save the value as text 00(and not a number), then add a text input on the page.
  5. Set the Initial content as yourDropdown'value.
  6. In the condition tab, add a condition that says that when the value is 0, the text inputs initial content should be 00.
    image.
  7. Now the dropdown value is stored in the text input as a text. So to get the value as text call the textInput's value
  8. Hide the text input.

I’ve setup this example here for you to look at

Yes i know this is too much for such a simple issue but i guess you understand as i’ve explained above why this occurs. That’s why i call it a beatiful problem :grinning:

3 Likes