react-autosuggest icon indicating copy to clipboard operation
react-autosuggest copied to clipboard

[QUESTION] - Select suggestion programmatically

Open simplecommerce opened this issue 6 years ago • 4 comments

Hi,

Is there a way to select a suggestion programmatically?

What I am trying to accomplish is the following:

When a user types in the autosuggest, if there is a single match, select (click) that suggestion automatically.

Hope you guys can help!

Thanks!

simplecommerce avatar Jun 14 '19 15:06 simplecommerce

Are you trying to achieve something similar? #658

themakerman avatar Jul 04 '19 03:07 themakerman

@themakerman thanks for your comment, no I simply wanted to be able to call a function when a single match (suggestion) is available, and have it do something. In my case when I type something in the input and only 1 match appears, it automatically clicks on it. I was able to achieve it by putting a ref on the suggestions and calling the ref.click(). Its not ideal but it works. I was wondering if there was any other way that would be better to do it.

simplecommerce avatar Jul 04 '19 10:07 simplecommerce

So do u have any suggestions for my issue?

themakerman avatar Jul 05 '19 15:07 themakerman

I've got the same issue. Our use case is to create a new item from a dialog. We'd like to have it insert the new one into the list and have it be selected.

captrespect avatar Jun 04 '20 03:06 captrespect