Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE REQUEST: Give option to NOT clear the search when canceling search. #106

Open
tazbill opened this issue Jun 16, 2021 · 2 comments
Open

Comments

@tazbill
Copy link

tazbill commented Jun 16, 2021

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

@tazbill
Copy link
Author

tazbill commented Jun 16, 2021

This would also solve the issue raised in #86

@SnekCode
Copy link

SnekCode commented Aug 1, 2021

@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}
/>
Screen.Recording.2021-08-01.at.3.40.15.AM.mov

What are your thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants