Cannot get DOM-elements of `<Select />`
See original GitHub issueWhat you did
I use <Select showSearch />
as a auto-complete field
What you would like to happen
I want to get the DOM-element of the search-input to focus it programatically.
The used rc-select
already provide an API to get the DOM-element.
What actually happened
I’m not able to get the rc-select
element from antd’s <Select />
.
Online demo
http://codepen.io/sokki/pen/rLNQQa?editors=0011
Environment Information
- antd 1.2.1
Possible Solution
add ref="select"
to <RcSelect />
in the render
method of antd’s <Select />
:
https://github.com/ant-design/ant-design/blob/master/components/select/index.jsx#L44
<RcSelect {...this.props}
ref="select"
className={cls}
optionLabelProp={optionLabelProp || 'children'}
notFoundContent={notFoundContent} />
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
javascript - can't select element with dom, after creating that ...
Move the event handler into the first function so that it isn't triggered until the element is created and added to the document....
Read more >How do I select elements when I already have a DOM element?
If you have a variable containing a DOM element, and want to select elements related to that DOM element, simply wrap it in...
Read more >Searching: getElement*, querySelector*
If an element has the id attribute, we can get the element using the method document.getElementById(id) , no matter where it is. For...
Read more >How To Access Elements in the DOM - DigitalOcean
The easiest way to access a single element in the DOM is by its unique ID. You can get an element by ID...
Read more >Can't select element (JavaScript) | Sololearn: Learn to code for ...
I'm trying to make a project, it's porpuse is to basically update the navigation bar of a website I have to all pages...
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
using
ReactDOM.findDOMNode(this.refs.select).click();
can also focus the search input.Trace: https://github.com/ant-design/ant-design/issues/3790