Clear Selection via an external button click
See original GitHub issuedownshift
version: 1.31.16node
version: 8.11.12npm
(oryarn
) version: 5.6.0
What you did: I have integrated downshift in a form in my react application to display a list of users fetched from an API. I have a button in this form, which is used to clear all the fields. However, I am not able to clear the autocomplete text field of Downshift upon clicking the button.
So, is there a way that I can use the clearSelection
method in another function?
If not, is there any other alternative?
Thank you.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Clear dropdown selection on radio button click - Stack Overflow
I have a set of radio buttons. When primary is selected, the Primary Company field is hidden. I would also like to at...
Read more >Clear data entry from gallery when button "on sele...
Hi all. I have a gallery which is filtered based on a dropdown selection. When i select e.g "1" in my dropdown a...
Read more >Uploading Files by Using External Button - Kendo UI for Angular
Create custom buttons to upload and clear the selected files by utilizing the uploadFiles and clearFiles methods in the click handler function.
Read more >How to reset all form values using a button in HTML
You can easily reset all form values using the HTML button using <input type=”reset”> attribute. Clicking the reset button restores the form ...
Read more >Clear cookies and site data in Firefox - Mozilla Support
To remove selected items, select an entry and click Remove Selected. Click Save Changes. In the Removing Cookies and Site Data confirmation dialog...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Here’s a permalink: https://github.com/paypal/downshift/blob/e1273c8df4d6b33365d8f2bf69cee9d6f8b97760/stories/examples/controlled.js
You can do that already. That’s how refs in react work. No need to change the code.
That said, it would be very imperative so it’d probably be better to do this a different way.
If you want to control the selectedItem state outside downshift, the solution is to use control props. See the documentation for how to accomplish that. There’s also an example for this as well.
Either way, this is definitely possible, so I’ll go ahead and close this issue. Thanks!