Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/toggle picker android #462

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"/src"
],
"dependencies": {
"@react-native-picker/picker": "^1.8.3",
"@react-native-picker/picker": "^1.16.7",
"lodash.isequal": "^4.5.0"
},
"devDependencies": {
Expand Down
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ export default class RNPickerSelect extends PureComponent {
Keyboard.dismiss();
}

if (this.pickerRef && Platform.OS == 'android') {
this.pickerRef.focus();
};
Comment on lines +251 to +253

Choose a reason for hiding this comment

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

Should take into account whether picker is currently visible or not.

Suggested change
if (this.pickerRef && Platform.OS == 'android') {
this.pickerRef.focus();
};
if (this.pickerRef && Platform.OS === 'android') {
if (!showPicker) {
this.pickerRef.focus();
} else {
this.pickerRef.blur();
}
}

Copy link

Choose a reason for hiding this comment

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

FYI, this didn't work, using only this.pickerRef.focus() did.


const animationType =
modalProps && modalProps.animationType ? modalProps.animationType : 'slide';

Expand Down Expand Up @@ -508,6 +512,7 @@ export default class RNPickerSelect extends PureComponent {
<View style={style.headlessAndroidContainer}>
{this.renderTextInputOrChildren()}
<Picker
ref={(ref) => {this.pickerRef = ref}}
style={[
Icon ? { backgroundColor: 'transparent' } : {}, // to hide native icon
defaultStyles.headlessAndroidPicker,
Expand All @@ -533,6 +538,7 @@ export default class RNPickerSelect extends PureComponent {
return (
<View style={[defaultStyles.viewContainer, style.viewContainer]}>
<Picker
ref={(ref) => {this.pickerRef = ref}}
style={[
Icon ? { backgroundColor: 'transparent' } : {}, // to hide native icon
style.inputAndroid,
Expand Down