Focus $refs Input
See original GitHub issueI see in the FAQ that you can change the input programmatically by using
this.$refs.name.searchInput
but can’t figure out a way to use focus(), ie
this.$refs.name.focus()
this.$refs.name.searchInput.focus()
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How to set focus on an input field after rendering?
Set ref="nameInput" on my input field in the render function, and then call: this.refs.nameInput.getInputDOMNode().focus();. But where should I ...
Read more >Refs and the DOM - React
Refs provide a way to access DOM nodes or React elements created in the render method. ... textInput} /> <input type="button" value="Focus the...
Read more >Focus management with Vue refs - Learn web development
The focus management problem · Reload your page, then press Tab . You should see a focus outline on the input for adding...
Read more >How to Set Focus on an Input in React
Call the focus() method on the ref element. Set focus on input on button click. import {useRef} from 'react';function App() {const ...
Read more >How to Set Focus On Element After Rendering With React
In this guide, learn how to set focus on an element after JavaScript's React component renders it, using functional and class components.
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
@AndrewBogdanovTSS if you’re worried about it being too hacky (since my previous comment was the entire document), I would actually recommend doing it like this:
In this scenario, it is a native element method
.focus
, which I think is better left for the user to implement in lieu of vue-autosuggest handling it via prop or otherwise.I’m not sure this answers the question - if the original question was “how do I trigger a focus event (such that the input element itself is focused and typing will occur within the input)” then I am looking for a solution for this as well.