reactjs / react-autocomplete

WAI-ARIA compliant React autocomplete (combobox) component
MIT License
2.17k stars 532 forks source link

How to get highlighted item #291

Closed LekovicMilos closed 6 years ago

LekovicMilos commented 6 years ago

Hi guys,

I have a problem with getting the currently highlighted item. Is there a way to do that at all? I want to change the value of input with highlighted item's value, while I press keys Up and Down. I don't see anywhere callback function or smt, to put ref on the highlighted item. Do you have suggestion how to do that?

Thanks in advance!

quachsimon commented 6 years ago

I'm not sure how you would get the highlighted item but, if you open the React console log (in Chrome) you can see that the component has a state called highlightedIndexwhich indicates the value that is higlighted.

LekovicMilos commented 6 years ago

I've got it in this.input.state.highlightedIndex, thanks! Now, I need another thing. How can I keep the menu opened after changing the value fo the input?

LekovicMilos commented 6 years ago

You helped me, so I am closing this issue. The problem that I have with menu being open after value change is on this url now: https://github.com/reactjs/react-autocomplete/issues/292