Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,12 @@ export default class RNPickerSelect extends PureComponent {
onValueChange={this.onValueChange}
selectedValue={selectedItem.value}
{...pickerProps}
onFocus={() => {
Keyboard.dismiss();
if (pickerProps.onFocus) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about how this repo does it, but in E/App we would also check to make sure that onFocus is also a function before calling it. Should we do that here? It seems like it would be nice, so that the lib doesn't crash if someone passes something that isn't a function.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was what I initially thought too. But I check for the other callback (onOpen, onClose) and none of them check if it's a function. I think it's fine to let the app that implement the library to make sure a function is passed, just like React Native component that will throw an error if you give onPress an integer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tgolen, thoughts?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I think that works for me. I'll be interested to see if they request something similar in the upstream repo's PR.

pickerProps.onFocus();
}
}}
>
{this.renderPickerItems()}
</Picker>
Expand All @@ -557,6 +563,12 @@ export default class RNPickerSelect extends PureComponent {
onValueChange={this.onValueChange}
selectedValue={selectedItem.value}
{...pickerProps}
onFocus={() => {
Keyboard.dismiss();
if (pickerProps.onFocus) {
pickerProps.onFocus();
}
}}
>
{this.renderPickerItems()}
</Picker>
Expand Down