question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow choice value to be 0

See original GitHub issue

I have a choice which value is 0, and it seems like nothing happens when I click this option. ( It does not trigger the change event )

const choices = [{
  value: 0,
  label: 'Label 1'
}]

I tried to change the value to any number other than zero, and it works fine.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

4reactions
jeffperrincommented, Jan 8, 2018

Looks like this is caused by this line: https://github.com/jshjohnson/Choices/blob/master/assets/scripts/src/choices.js#L1142

Anything ‘falsey’ will not trigger the change event (ie; 0 or an empty string). I’m not sure what the original reason for this check was, but it seems like it should explicitly be looking for null or undefined instead.

0reactions
jonnyscholescommented, May 2, 2018

Great to see this is fixed! Would it be possible to cherry pick this into master as a patch release? More than happy to submit a PR to master with just the changes from #349 if thats helpful 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

choices[].value = 0 is converted to a table. · Issue #2404 - GitHub
choices [].value allows to set a table as value when it clearly can do only strings and integers. I found out this by...
Read more >
Display or hide zero values - Microsoft Support
Display or hide all zero values on a worksheet​​ Click File > Options > Advanced. Under Display options for this worksheet, select a...
Read more >
How to Set Choice Field Default Value to Blank in SharePoint?
By default, when you create a new choice field, the very first choice you entered is also set as “Default value” in field...
Read more >
why select option value if zero post empty - Stack Overflow
I am if select value="0" option and this post, it retuns the value with no problem. But, when I use value = 0...
Read more >
<input type="range"> - HTML: HyperText Markup Language
elements of type range let the user specify a numeric value which must be no ... option { padding: 0; } input[type="range"] {...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found