day8 / re-com

A ClojureScript library of reusable components for Reagent
https://re-com.day8.com.au
MIT License
799 stars 145 forks source link

single-dropdown selection of false :id value #162

Closed jcthalys closed 2 years ago

jcthalys commented 7 years ago

Hi! I would like to understand if this is really an issue or not.

When you select Partners the id with a false value, the dropdown does not leave the selection on the screen instead it Owner works perfectly.

(let [equipment-is-owner? (reagent/atom false)]
                [re-com/single-dropdown
                 :width "220px"
                 :choices [{:id true :label "Owner"}
                           {:id false :label "Partners"}]
                 :model equipment-is-owner?
                 :on-change #(swap! equipment-is-owner? not)])
MawiraIke commented 2 years ago

This issue seems to be caused by this line which fails when the value of the model is false. Currently the selection is actually made but the choice is not displayed. Having a placeholder passed to the dropdown will default to showing the placeholder instead. Also, changing the check from (if @internal-model ...) to (if (some? @internal-model) ...) fixes the issue. Pushing a fix for this.