Open
Conversation
|
Any updates ? ) We need it ! |
|
Needed feature here, but @JoFlo07 you have broken tests in your PR |
Author
|
I had a look into it and it seems like the failure of the test is related to the jest.config of these tests not to the changes I made. Can you guys have a look at your test suite? |
|
Patch based on this PR here: diff --git a/node_modules/react-native-picker-select/src/index.js b/node_modules/react-native-picker-select/src/index.js
index 7ae6730..da08215 100644
--- a/node_modules/react-native-picker-select/src/index.js
+++ b/node_modules/react-native-picker-select/src/index.js
@@ -253,6 +253,14 @@ export default class RNPickerSelect extends PureComponent {
Keyboard.dismiss();
}
+ if (this.pickerRef && Platform.OS === 'android') {
+ if (!showPicker) {
+ this.pickerRef.focus();
+ } else {
+ this.pickerRef.blur();
+ }
+ }
+
const animationType =
modalProps && modalProps.animationType ? modalProps.animationType : 'slide';
@@ -511,6 +519,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,
@@ -536,6 +545,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, |
Comment on lines
+251
to
+253
| if (this.pickerRef && Platform.OS == 'android') { | ||
| this.pickerRef.focus(); | ||
| }; |
There was a problem hiding this comment.
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(); | |
| } | |
| } |
There was a problem hiding this comment.
FYI, this didn't work, using only this.pickerRef.focus() did.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This allows to programmatically open the picker on android devices.
See open Issue.