React-select: Triggering Select to Open from other component

Created on 6 Jul 2015  路  2Comments  路  Source: JedWatson/react-select

I'm trying to make a link open up the react-select component. Anyone know a way to do this with React?

Most helpful comment

This is probably a hack, but here's how I think I'm going to do it:

React.createClass({
  onClick(event){
    const fieldInput = this.refs.fieldInput;
      if (!fieldInput.state.isOpen) {
        fieldInput.handleMouseDown(event);
      }
  },
  render(){
  <div onClick={this.onClick}
    <Select ref='fieldInput'
      options={this.props.options}
      value={this.props.value}
      onChange={this.onChange}/>
  </div>
  }
});

All 2 comments

I am trying to do a similar thing where I need to wrap the react-select around a parent dropdown-button. On click of the parent dropdown-button, I want to trigger opening a react-select (with focus in the search/input. Does anyone know how to do this?

This is probably a hack, but here's how I think I'm going to do it:

React.createClass({
  onClick(event){
    const fieldInput = this.refs.fieldInput;
      if (!fieldInput.state.isOpen) {
        fieldInput.handleMouseDown(event);
      }
  },
  render(){
  <div onClick={this.onClick}
    <Select ref='fieldInput'
      options={this.props.options}
      value={this.props.value}
      onChange={this.onChange}/>
  </div>
  }
});

Was this page helpful?
0 / 5 - 0 ratings