From c32b327f2313c24b19ff81496aee1979c7eb2833 Mon Sep 17 00:00:00 2001 From: jdescottes Date: Sun, 25 Oct 2015 00:18:01 +0200 Subject: [PATCH] Fix #322 : Save As button no longer works on offline builds --- src/js/utils/FileUtilsDesktop.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/js/utils/FileUtilsDesktop.js b/src/js/utils/FileUtilsDesktop.js index ac2dc26f..333abca2 100644 --- a/src/js/utils/FileUtilsDesktop.js +++ b/src/js/utils/FileUtilsDesktop.js @@ -25,13 +25,16 @@ deferred.resolve(fileInputElement.value); }; - fileInputElement.click(); - - fileInputElement.addEventListener('change', changeListener); - // there is no way to detect a cancelled fileInput popup - // as a crappy workaround we add a click listener on the document - // on top the change event listener - document.addEventListener('click', changeListener); + // fix for issue #322 : + window.setTimeout(function () { + fileInputElement.click(); + fileInputElement.addEventListener('change', changeListener); + // there is no way to detect a cancelled fileInput popup + // as a crappy workaround we add a click listener on the document + // on top the change event listener + // todo : listen to dirty check instead + document.addEventListener('mousedown', changeListener); + }, 50); return deferred.promise; },