material-ui-search-bar
material-ui-search-bar copied to clipboard
FEATURE REQUEST: Give option to NOT clear the search when canceling search.
This originally came from me trying to override the cancel functionality all together.
<SearchBar
value={searchText}
onChange={handleSearchTextChanged}
closeIcon={<SearchIcon style={{ color: grey[500] }} />}
onRequestSearch={performSearch}
onCancelSearch={performSearch}
/>
This SHOULD have allowed me to keep the search icon visible and allow the user to click it when they wanted to search without worrying about knowing to hit enter.
However, the setValue('') is the first line called in the cancel method regardless of whether or not we have custom functions.
I propose adding a new property cancelClearsText or something far less ridiculous than that. Then in the cancel method, check for this property before clearing the search text.
In the meantime, I'm just going to REset the search text after a cancel and will have to wrap the performSearch in a cancel handler
This would also solve the issue raised in #86
@tazbill instead of a new property what if the check was for the onRequestSearch function and if that function existed then the search button wouldn't be replaced by the clear button.
I'm thinking this would look like:
<SearchBar
value={searchText}
onRequestSearch={performSearch}
/>
https://user-images.githubusercontent.com/46388252/127773034-cb770db4-fe17-4a8a-96a3-dcf316535cf0.mov
What are your thoughts?