enkidevs / react-search-input

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

Change or remove placeholder #135

Closed ChristianTheMinery closed 7 years ago

ChristianTheMinery commented 7 years ago

Currently, there doesn't seem to be any way to replace or remove the 'Search' placeholder attribute. This feature would be greatly appreciated!

mathieudutour commented 7 years ago

just use the placeholder prop?

ChristianTheMinery commented 7 years ago

The placeholder prop doesn't accept an empty string (or null, or false) if I don't want a placeholder, but instead defaults back to 'Search'.

mathieudutour commented 7 years ago

probably because the default type of the input is search. Change it to text and there shouldn't be anything

ChristianTheMinery commented 7 years ago

No dice - I believe the issue would be on line 46 of index.js:

inputProps.placeholder = inputProps.placeholder || 'Search'

Seeing as an empty string is a falsey value, this line will return 'Search' if an empty string is passed.

I can get around the issue by passing a string that contains a space, which no longer evaluates as empty.