question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Focus $refs Input

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
darrenjenningscommented, Sep 25, 2019

@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:

// <vue-autosuggest ref="autosuggest"
this.$refs.autosuggest.$el.querySelector("input").focus();

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.

1reaction
chrispappascommented, Oct 31, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found