question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clear Selection via an external button click

See original GitHub issue
  • downshift version: 1.31.16
  • node version: 8.11.12
  • npm (or yarn) 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:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
kentcdoddscommented, Jun 22, 2018

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found