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.

[Bug] Suggestions not rendered when using onFocus for input in renderInputComponent

See original GitHub issue

Are you reporting a bug?

Yes

  • Please create a Codepen that demonstrates your issue. You can start from the [Basic example] CodePen link

  • Steps to reproduce the issue

    1. Focus on the input field
    2. Type c, and wait for suggestions to appear

    Observed behaviour: Suggestions does not open

    Expected behaviour: Suggestions should open

If you go ahead and remove the onFocus prop from the input(line 88) it would work as expected.

Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
JStrebeykocommented, Jun 8, 2018

@apandichi the workaround works on my end - thanks a ton! 😃

1reaction
apandichicommented, Nov 21, 2017

The bad news is: the same problem happens with onChange instead of onFocus. The good news is: there is a workaround.

function renderInputComponent(inputProps) {
  return <input {...inputProps} onFocus={(ev, val) => {
      handleInputFocus();
      inputProps.onFocus(ev, val);
    }
   }/>
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

focusInputOnSuggestionClick throwing error when ... - GitHub
Create an input using renderInputComponent; Create a ref to the input on the class ... No more error and everything is working correctly....
Read more >
reactjs - Autosuggest/Combobox suggestion wont display
In getSuggestions you need to return an array directly, not an object. see https://codesandbox.io/s/w04jpzjr4k.
Read more >
React Autosuggest
When the suggestions list is long, you may want to make it scrollable. Note that the suggestions are rendered even when the input...
Read more >
Focus management with Vue refs - Learn web development
It's important to note that a ref needs to be unique within a component. No two elements rendered at the same time should...
Read more >
3 ways to autofocus an input in React that ALMOST always work!
Deep dive into the autofocus attribute, the focus() method, the autoFocus prop, the useRef hook and callback refs.
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