From c53c5b57f82b77e091981ff39a33a00a779b16c3 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Wed, 17 Jan 2018 11:43:12 -0800 Subject: [PATCH] Fix issue where change event would not fire on file selection --- js/fileUtils.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/fileUtils.js b/js/fileUtils.js index 876448d7..b17b046c 100644 --- a/js/fileUtils.js +++ b/js/fileUtils.js @@ -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); });