moroshko / react-autosuggest

WAI-ARIA compliant React autosuggest component
http://react-autosuggest.js.org
MIT License
5.97k stars 587 forks source link

Autosuggest linking #424

Open jtheo314 opened 7 years ago

jtheo314 commented 7 years ago

In regards to using React-Autosuggest, how would one be able to make clicking one of the autosuggest options and pressing enter/submit link to a page within the site?

moroshko commented 7 years ago

Sorry, the question is not clear. Could you rephrase it? What do you want to happen when suggestion is clicked? What do you want to happen when Enter is pressed?

jtheo314 commented 7 years ago

When the suggestion is clicked, it already shows up within the form. I'd like it to link to a certain page within the site when enter is pressed, based on what is populated in the form

moroshko commented 7 years ago

You can try to provide inputProps.onKeyDown, validate that Enter is pressed, and then navigate.

jtheo314 commented 7 years ago

https://github.com/jnierendorf/Liberty-Hacks/blob/Jason-branch/src/js/components/Searchbar.js

I'm currently fooling around with this code from your codepen to see how it works exactly before deciding whether I want to implement it in this website or not. I was wondering how I can make it so one of the options suggested, once the user clicks on it and presses enter, can link to one of the other pages on this website. For example, once 'skype' is selected and the user clicks Enter, they will be redirected to the website's Skype page.

Thank you!