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.

Erasing File Input value on click

See original GitHub issue

Hello,

First, thanks for the really great project. This has made our lives alot easier.

We use redux/redux-form 5.3.3 to manage our state. So we represent the files as a field object, those fields are tied to inputs. If the value of that input changes it dispatches a redux event of redux-form/CHANGE for the field that was associated with that input.

What that means for this libraries interaction, is that when someone clicks on a dropzone, it sets the value to null, which erases the value from our store. We have gotten around this by storing the original value in the components state and using that when needed.

My question is, would it be possible or wanted to remove the erasing the file when dropzone is clicked? What are your thoughts?

If acceptable I would be able to write the code and tests for it.

I can also think of several alternatives to removing including

  1. store the originalValue and on cancel, set the input value to the originalValue
  2. Create an option to react-dropzone that would allow bypassing the always clear function
  open() {
    this.fileInputEl.value = null; //this is the line i mean
    this.fileInputEl.click();
  }

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:9

github_iconTop GitHub Comments

2reactions
Austiocommented, Sep 29, 2016

@okonet i like that, looks like we are all busy but if i get a couple hour opening at night will whip up a PR for this.

0reactions
stale[bot]commented, Sep 6, 2017

This issue has been automatically marked as stale because it has not had recent activity in the past 60 days. It will be closed if no further activity occurs. If the problem persists please comment here to bump your issue. Thank You - React Dropzone Maintaners

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I clear an HTML file input with JavaScript?
There's 3 ways to clear file input with javascript: set value property to empty or null. Works for IE11+ and other modern browsers....
Read more >
How To Clear Input Field on Focus - W3Schools
Click on the input field to clear it: ... When the input field gets focus, replace its current value with an empty string...
Read more >
HTML | Clearing the input field - GeeksforGeeks
Method 2: Clearing Input with the help of button. Syntax: <button onclick="document.getElementById('InputID').value = ''>. Approach: Create a ...
Read more >
How Do I Remove a Specific File From an Input on Click?
So basically it is impossible to do this with a HTML input element? Some moron created it in such a way that you...
Read more >
How to remove one image file from input file multiple - SitePoint
i have five input type file to choice image for upload,but when i click remove one image all image was delete,i just want...
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