-
Notifications
You must be signed in to change notification settings - Fork 17.1k
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
37.2.6
What operating system(s) are you using?
macOS
Operating System Version
macOS 15.5
What arch are you using?
arm64 (including Apple Silicon)
Last Known Working Electron version
No response
Does the issue also appear in Chromium / Google Chrome?
Yes
Expected Behavior
The file picker (<input type=file>, showOpenFilePicker) should not allow selecting directories, only files.
Actual Behavior
The file picker allows selecting directories if they match some of the given file extensions. The directory is exposed to JS as a File / FileSystemFileHandle, but fails to be read.
For example, the following code:
window.showOpenFilePicker({
multiple: true,
types: [
{
accept: {
"application/octet-stream": [".foobar"],
},
},
],
});
allows choosing directories named with ".foobar" even though they are not files. Trying to read the file fails with an unclear error message.
repro.mov
Testcase Gist URL
https://gist.github.com/jtbandes/98f048be7671b36105e656939c64d633
Additional Information
I have also filed an issue upstream with Chrome at https://issues.chromium.org/issues/438779953
However, I have noticed that Electron already has some custom behavior around file picking of directories (see below), so I am also filing a bug here, in case it makes sense to add any workarounds or patches to Electron.