nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit 596de297243f53b33845384f74331670b30cd348
parent b7c6cbfadcc72c9ee1d5048087c840398422a72c
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Fri, 16 Dec 2016 18:19:06 +0300

[tracks] fixed file select dialog behavior (duplicate files, not opening same file second time)

create new fileinput on each invocation, remove old before creating new one

Diffstat:
Msrc/lib/file-read/index.js | 14++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/lib/file-read/index.js b/src/lib/file-read/index.js @@ -17,13 +17,15 @@ function arrayBufferToString(arBuf) { const selectFiles = (() => { let fileInput; return function selectFiles(multiple = false) { - if (!fileInput) { - fileInput = document.createElement('input'); - document.body.appendChild(fileInput); - fileInput.type = 'file'; - fileInput.multiple = !!multiple; - fileInput.style.display = 'none'; + if (fileInput) { + document.body.removeChild(fileInput); } + fileInput = document.createElement('input'); + document.body.appendChild(fileInput); + fileInput.type = 'file'; + fileInput.multiple = !!multiple; + fileInput.style.display = 'none'; + const result = new Promise(function(resolve) { fileInput.onclick = (e) => console.log('click', e); fileInput.addEventListener('change', function() {