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

How to clear Search box on button click event #27

Open
gdhelp03 opened this issue Oct 13, 2020 · 3 comments
Open

How to clear Search box on button click event #27

gdhelp03 opened this issue Oct 13, 2020 · 3 comments

Comments

@gdhelp03
Copy link

gdhelp03 commented Oct 13, 2020

Search field is working fine but I want to clear Search Field on Button Click.
One more Question How can I change for color

@nutboltu
Copy link
Owner

@gdhelp03

  • this clear feature is not available in this component.
  • Which colour would you intend to change?

@chenhualihx
Copy link

I got a solution on how to add the clear feature by adding a button and its event handler:
let x = document.querySelector("input.react-search-field-input");
x.value='';

@nutboltu
Copy link
Owner

@chenhualihx
I believe the ideal approach should be handling the clear option using props without any breaking changes.
Your approach would be an option but the side effect is it would mutate the component.
The proposed solution would be

  • Add a new prop (clearOption) and mark it false by default.
  • if the prop is true, introduce a close button, (Though I am still thinking what should be the right place to display this button).
  • clear the value while clicking this button.

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

3 participants