input type="file" weird behavior
See original GitHub issueIt seems that reused input elements with type “file” do not clear their selected file correctly see: http://jsfiddle.net/mnypy1do/3/
also if you explicitly do: <input type="file" value=""/>
(http://jsfiddle.net/mnypy1do/4/)
the same thing happens
I don’t know what the proper behavior here should be, probably the best would be to pass in the FileList
back into the input via files
prop when something gets selected
The only problem is that getting an empty FileList
is not an obvious thing, can’t just do new FileList()
, you have to
var input = document.createElement("input");
input.type = "file";
var emptyFiles = input.files;
see: http://jsfiddle.net/mnypy1do/5/
and passing null wont worke either, unless there would be special handling for this (input.files = null) does nothing
Any thoughts on this? Thanks
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Input type="file" showing weird behavior when used along ...
You are directly trying to mutate the state, productPicture=URL.createObjectURL(e.target.files[0]) which is wrong. Here you are not setting ...
Read more >input type="file" weird behavior · Issue #187 · preactjs/preact
That being said, this behavior is definitely a bit odd. We normalize input values in a similar way, it just doesn't apply for...
Read more >Strange behavior during file upload - CodeRanch
Strange behavior during file upload ... Please select the document type ... <input type= "file" class = "custom-file-input" id= ...
Read more >Javascript – IE Input type text weird behavior – iTecNote
Javascript – IE Input type text weird behavior. htmlinternet-explorerjavascript. I have a google suggest like utility on my page. It automatically fills a ......
Read more >Input type="file" showing weird behavior when used along ...
You are directly trying to mutate the state, productPicture=URL.createObjectURL(e.target.files[0]) which is wrong. Here you are not setting state. To set actual ...
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 FreeTop 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
Top GitHub Comments
react version: https://jsfiddle.net/5cuaptd6/2/
Cool, thanks alot!