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

Programmatically focus picker #82

Closed
sidraval opened this issue Sep 25, 2018 · 12 comments
Closed

Programmatically focus picker #82

sidraval opened this issue Sep 25, 2018 · 12 comments

Comments

@sidraval
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I have a form with several fields, a couple text inputs followed by a picker. I'd like to use the 'Next' button on the iOS/Android keyboard to programmatically focus the picker.

Describe the solution you'd like
A method that programmatically focuses the picker.

@kdonovan
Copy link

It's apparently undocumented, but have you tried togglePicker()?

@lfkwtz
Copy link
Collaborator

lfkwtz commented Sep 30, 2018

@sidraval does togglePicker solve your needs on iOS?

For Android, this issue exists on the feature req board as #22

@lfkwtz
Copy link
Collaborator

lfkwtz commented Oct 13, 2018

@sidraval let me know if that solves it so i can close this out

@sidraval
Copy link
Contributor Author

@lfkwtz My project wrapped up, so I can't test togglePicker() anymore – I'll close this out now

@mikerodham
Copy link

Just to confirm, yes this.refs['picker'].togglePicker() worked.

@dextermb
Copy link

dextermb commented Jun 3, 2019

Just to confirm, yes this.refs['picker'].togglePicker() worked.

Calling togglePicker outside of the component does not seem to work for me:

this.select.current.togglePicker();

<RNPickerSelect
    ref={this.select}
    onValueChange={fn}
    items={[]}
/>

@dextermb
Copy link

dextermb commented Jun 4, 2019

Just to confirm, yes this.refs['picker'].togglePicker() worked.

Calling togglePicker outside of the component does not seem to work for me:

this.select.current.togglePicker();

<RNPickerSelect
    ref={this.select}
    onValueChange={fn}
    items={[]}
/>

This seems to work on iOS but not android.

@lfkwtz
Copy link
Collaborator

lfkwtz commented Jun 4, 2019

see link above ^ #22

@llaine
Copy link

llaine commented Oct 16, 2019

Outside of the component calling open works for me

class InputSelect {
  private picker;
  render() {
    return (
      <RNPickerSelect ref={e => this.picker = e} ... />
    )
  }
  open() { this.picker.togglePicker() }
}

@iman2420
Copy link

TypeError: refAlphabetList.current.togglePicker is not a function

@tara-singh-danu
Copy link

togglePicker() not working on Android.

@shoki61
Copy link

shoki61 commented Nov 4, 2022

#424 (comment)
this solution worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants