Estoy usando "electron": "^16.0.7", estoy tratando de seleccionar el directorio usando "webkitdirectory". Ya sea que seleccione los archivos en lugar de seleccionar la carpeta. Y luego recupere la ruta del archivo usando otra función. Mientras que el "onchange" selecciona archivos en lugar de carpetas.
El siguiente código crea un elemento como este,
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)) } } }}