I am using "electron": "^16.0.7", I am trying to select directory by using "webkitdirectory". Whether it select's files instead of selecting folder. And then retrieve the path of file from by using another function. While the "onchange" selects file instead of folders.
The below code creates an element like this,
input.current = document.createElement('input')
input.current.type = 'file'
input.current.webkitdirectory = true
input.current.msdirectory = true
input.current.onchange = (e) => {
const { files } = input.current
watchFiles(files)
input.current.value = ''
}
function watchFiles(files: FileList) {
if (files) {
for (let i = 0; i < files.length; i++) {
const path = files[i] && (files[i].path || files[i].name)
if (path) {
const newId = uniqid()
dispatch(addProject(newId, path))
}
}
}
}