react-native-picker / picker

Picker is a cross-platform UI component for selecting an item from a list of options.
MIT License
1.51k stars 282 forks source link

Picker for city, I want to put enable=false on the already chosen city, but that renders entire picker disabled #252

Open C-odes opened 3 years ago

C-odes commented 3 years ago

Hi

So here's my issue:

I want the user to be able to pick the city in a picker. I have the following line for enabled property:
<Picker.Item label="New York" value="New York" enabled={ selectedValue == "New York" ? false : true />

The point is, you shouldnt be able to pick the same city twice, and it also makes it quite visible which city is currently chosen.

But here's what happens instead:

You have lets say preselected is Paris, you tap on the picker, it shows all active except for New York, once you pick New York, it's chosen. But now, because the chosen one IS enabled=false , you cant open the picker again to pick a different city...

I guess I could change color of the item but you would still be able to pick it... which is stupid.

hixus commented 3 years ago

Found out this too when using this with placeholder. However it's possible to open picker from arrow but it's still quite unusable for any user. Enabled=false should affect only the item in picker list not the input field that shows currently selected item.

donni106 commented 3 years ago

i found https://github.com/react-native-picker/picker/pull/236 and think this should behave as expected by @C-odes. i could achieve that input field is always pressable and the selected item inside of the picker is visually disabled (still pressable).