Programmatically focus a Select
See original GitHub issueIt is possible to focus Textfields, buttons with a ref. This isn’t working with select.
I do not mean autoFocus
. I want to focus on a select field when a user clicks on a button.
My code:
<FormControl className="select100"> <Select ref={(formControll) => { this.formControll = formControll; }} native value={aValue} input={<Input id="integer" />} > {possibleOptions.map((item, key) => { return (<option value={item} key={key}>{item}</option>) })} </Select> </FormControl>
If I now try to set the focus on the select with:
this.formControll.focus();
it isn’t working.
Tech | Version |
---|---|
Material-UI | 1.0.0-beta.24 |
React | 16.2.0 |
browser | Chrome |
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Programmatically set focus on select · Issue #1212 - GitHub
Hello, How do I set the focus via JS on the bootstrap-select? I tried the focus() function on the select tag, and in...
Read more >Set focus on specific select box - javascript - Stack Overflow
I have multiple select boxes in the pages. I want to set focus on first element of specific select box. Here it shows...
Read more >HTMLElement.focus() - Web APIs | MDN
Select the button to set focus on the text field. Focus on a button. This example demonstrates how you can set the focus...
Read more >Set focus to and select text in input field - OutSystems
Hi, I use the input_SetFocus widget to set the cursor in the SearchInput field together with an onfocus extended property to select the...
Read more >Set Focus on <select> Element on Page Load - EncodeDna.com
This post has two examples showing how to set focus and automatically expand select dropdown option on page load using HTML5 attribute and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sedi0861 https://codesandbox.io/s/8nj6jz8n38 If I change handleFocus to use your textInput ref it works
@sedi0861 It does? https://codesandbox.io/s/y79j9x8421