Fix issue where change event would not fire on file selection

This commit is contained in:
Jordan Eldredge 2018-01-17 11:43:12 -08:00
parent 7bcdcdebde
commit c53c5b57f8

View file

@ -34,6 +34,11 @@ export async function promptForFileReferences() {
// Can this fail? Do we ever reject?
const fileInput = document.createElement("input");
fileInput.type = "file";
// Not entirely sure why this is needed, since the input
// was just created, but somehow this helps prevent change
// events from getting swallowed.
// https://stackoverflow.com/a/12102992/1263117
fileInput.value = null;
fileInput.addEventListener("change", e => {
resolve(e.target.files);
});