I am creating an application with ReactJS and Material UI. I have an Input component inside a FormControl component. I would like to set the focus on the Input component when the user clicks in the FormControl (but still outside the Input component). How can this be achieved?
I have tried with refs but I was not able to do it:
<FormControl
onClick={this.textInput.focus()}
style={{ display: 'block', cursor: 'text' }}
>
<Input
error={this.props.error}
disabled={this.props.disabled}
ref={(input) => { this.textInput = input; }}
/>
</FormControl>