vrimar / construct-ui

A Mithril.js UI library
https://vrimar.github.io/construct-ui
MIT License
287 stars 23 forks source link

List with "false" item not triggering onSelect #16

Closed chocolatkey closed 4 years ago

chocolatkey commented 4 years ago

I've reproduced the issue in a simplified form in this flems

The first item in the list, with the value 0 cannot be selected (once unselected) because it is "false". I've think I've narrowed down the issue to these lines: https://github.com/vrimar/construct-ui/blob/master/src/components/query-list/index.ts#L396 https://github.com/vrimar/construct-ui/blob/master/src/components/query-list/index.ts#L451 where the selected item is first checked to be true. 0 is not true in JS, so the onSelect is never called.

If this is by design, then I can work around it by having all items' number values be +1, but if not, then I think this is a bug, because there are use cases where an item's value could be something that is considered "false".

vrimar commented 4 years ago

Fixed in v0.2.3.