sergiop / react-giphy-searchbox

Responsive and customizable search and select for Giphy's GIFs and Stickers.
https://sergiop.github.io/react-giphy-searchbox/
MIT License
48 stars 19 forks source link

Autofocus the searchbox prop #33

Closed jkcchan closed 3 years ago

jkcchan commented 4 years ago

Request: add prop to autofocus the select box on mount

sergiop commented 4 years ago

Ho @jkcchan, could you elaborate your request? It's not totally clear to me. What do you mean with "the select box"?

jkcchan commented 4 years ago

@sergiop thanks for the reply. I'm looking for a prop to autofocus the searchbox, using this HTML attribute https://www.w3schools.com/tags/att_input_autofocus.asp . The prop would toggle an autoFocus prop into this input element here: https://github.com/sergiop/react-giphy-searchbox/blob/243c54170682ffc0fe493c434f89236e6964a25a/src/components/SearchForm/SearchForm.js#L28-L36

sergiop commented 4 years ago

Thanks @jkcchan, now is more clear! 😉 I didn't know the autoFocus HTML attribute. Since the search input field is the only field we have inside the form, and this behavior looks always useful, I think we can simply add the autoFocus attribute without managing it with a prop. What do you think? I need to make some tests.