enkidevs / react-search-input

:mag: Simple react.js component for a search input, providing a filter function.
302 stars 72 forks source link

autoFocus prop to the input field #103

Closed reznord closed 7 years ago

reznord commented 7 years ago

@mathieudutour It would be better to add a prop to the input field so that the user can set the focus of the cursor when the search is invoked.

Would be happy to submit a PR

mathieudutour commented 7 years ago

Can't you already set the autoFocus prop?

reznord commented 7 years ago

Thanks for the quick reply. Was about to ping you on twitter :P

No, since the inputProps doesn't have that field in that which can be set.

mathieudutour commented 7 years ago

inputProps is the rest of the props. You can pass whatever you want

reznord commented 7 years ago

Thanks for the solution. Sorry for the issue. But in my opinion that should be added to the inputProps. Not sure whether that would be a good idea or not.

mathieudutour commented 7 years ago

what exactly would you add?

reznord commented 7 years ago

as in make it optional by passing inputProps.autoFocus = inputProps.autoFocus || null

mathieudutour commented 7 years ago

hum that's weird. Why would you default to null? That's the current behaviour (default to undefined), I don't see why we should write it explicitly

reznord commented 7 years ago

okay. Makes sense. Closing this issue.