Open williamgurzoni opened 3 months ago
same issue here
Same for me, haven't found a workaround yet since the action is not being triggered at all
I've got this issue after upgrading the library from 9.0.1
to 9.3.1
.
The difference in my case is that I do not use the placeholder, I actually removed it by passing placeholder={{}}
.
One of my item have a value of 0 and I cannot select it because of the change made here: https://github.com/react-native-picker/picker/commit/243ead2e226ea5441a7091beccc903e804922c18
const value = children[position]?.props?.value;
if (value) {
onValueChange(value, position);
}
The code is not calling onValueChange
for values that are considered false in Javascript: false, "", null, undefined, 0, etc
Not sure why this change was necessary, IMO it's up to the developer to interpret the value returned by the picker. If null is meant to represent the placeholder value, than it should be the developer responsibility to handle that null value from it's onValueChange
handler. I don't think the values should be muted from within the picker implementation.
So in other words, this bug should be transferred to the react-native-picker/picker
project
Describe the bug
After updating @react-native-picker/picker to version v2.7.7 the
onValueChange
event stopped working when the user presses the placeholder item. This is an Android only issue.The issue was cause by this PR: https://github.com/react-native-picker/picker/pull/571
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The
onValueChange
event should be fired consistently in both platforms when the user selects the placeholder item.Screenshots
N/A
Additional details
Reproduction and/or code sample
https://snack.expo.dev/@gurzoni/issue-rnpickerselect---android-not-firing-onvaluechange-for-placeholder-item?platform=android