Skip to content

Commit

Permalink
fix(converter): fix issue with input select not resetting properly
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentinTh committed Aug 9, 2023
1 parent b7bb9eb commit 39e3509
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/scripts/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ folderInput.addEventListener('drop', () => {
toggleDropAreaActive();
});

const toggleFolderPath = (path = null) => {
const toggleFolderPath = (path = null, fromSession = false) => {
if (!(folderMessage.querySelector('.folder-path') === null)) {
folderMessage.querySelector('.folder-path').remove();
}
Expand All @@ -89,7 +89,22 @@ const toggleFolderPath = (path = null) => {
chooseButton.innerText = 'choose a folder';
folderMessage.querySelector('#text').innerText = `or drag and drop the folder here`;
folderInput.setAttribute('nwworkingdir', os.homedir());

if ('data-path' in sessionStorage) {
sessionStorage.removeItem('data-path');
}
} else {
if (fromSession) {
const changeEvent = new Event('change');
folderInput.dispatchEvent(changeEvent);

const existingFile = new File([], '', {});
const dataTransfer = new DataTransfer();
dataTransfer.items.add(existingFile);

folderInput.files = dataTransfer.files;
}

chooseButton.innerText = 'change folder';
folderMessage.querySelector('#text').innerText = `selected folder path is`;
folderInput.setAttribute('nwworkingdir', path);
Expand All @@ -105,7 +120,8 @@ if ('data-path' in sessionStorage) {
dataPath = PathHelper.sanitizePath(
sessionStorage.getItem('data-path').toString().trim()
);
toggleFolderPath(PathHelper.sanitizePath(dataPath));

toggleFolderPath(dataPath, true);
submitButton.removeAttribute('disabled');
}

Expand Down

0 comments on commit 39e3509

Please sign in to comment.