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.

Choosing the same file doesn't trigger onChange

See original GitHub issue

This is only from initial testing, but wondering if anyone else can reproduce. Here is my scenario using similar markup as the readme:

  1. Click “Select a file!” button and select house.jpg. This triggers onChange, everything is fine.
  2. Click “Select a file!” button again and select house.jpg again. This does not trigger onChange. I would expect re-rendering would solve this issue but it doesn’t.

This is a really weird issue so again I’m just wondering if this is an actual problem with the component itself.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

335reactions
eduardoturconicommented, Feb 6, 2018

Another way to handle this is to set input value to ‘’. It could be done on the onChange event:

handleChange({target}) {
    const files = target.files
    target.value = ''
}
11reactions
nx-amzzzcommented, Apr 13, 2020
// handleChange is executing as usual
// handleClick basically empty the target.value i.e. event.target.value = ""
const handleClick = event => {
    const { target = {} } = event || {};
    target.value = "";
  };

<input type="file" onChange={handleChange} onClick={handleClick} />
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to detect input type=file "change" for the same file?
Create a function that fires 'onChange' that will read->store->compare metadata of the current file against the previous files. Then you can trigger your...
Read more >
Input file selection event not firing upon selecting the same file
The problem is when I am choosing the same file to upload @change handler (onFileChange) doesn't fire. This is different from Firefox in ......
Read more >
Input File change event not working - EncodeDna.com
When you choose a file for the first time, it will alert and show the file detail. Choose the same file again, the...
Read more >
Solved: on change of html input form element does not work...
Solved: In my custom widget html I have: in my widget (startup or onOpen) I have: on(this.uploadForm, "change",
Read more >
Upload same image not working - OutSystems
This is because OnChange even only gets triggered when you change the value in target control. So in your case if you select...
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