Skip to content

fix: return the original dropped File so Electron can resolve its path#152

Merged
rolandjitsu merged 1 commit into
mainfrom
fix/electron-drag-drop-path-1411
Jul 18, 2026
Merged

fix: return the original dropped File so Electron can resolve its path#152
rolandjitsu merged 1 commit into
mainfrom
fix/electron-drag-drop-path-1411

Conversation

@rolandjitsu

Copy link
Copy Markdown
Collaborator

What kind of change does this PR introduce?

  • Bug Fix
  • Feature
  • Refactoring
  • Style
  • Build
  • Chore
  • Documentation
  • CI

Did you add tests for your changes?

  • Yes, my code is well tested
  • Not relevant

If relevant, did you update the documentation?

  • Yes, I've updated the documentation
  • Not relevant

Summary

In a secure context (every Electron app, plus https/localhost) fromDataTransferItem resolved a FileSystemHandle and handed back handle.getFile()'s File. That File loses the on-disk path Electron's webUtils.getPathForFile() needs (electron/electron#33647), which broke drag-and-drop path access from v1.x onward.

Return the File captured synchronously from getAsFile() instead - it preserves the original File object identity Electron keys on - and only fall back to handle.getFile() when getAsFile() returned null (e.g. a cross-window drop). The durable handle is still attached either way, and directory traversal is unaffected.

Does this PR introduce a breaking change?

No.

Other information

In a secure context (every Electron app, plus https/localhost) fromDataTransferItem
resolved a FileSystemHandle and handed back handle.getFile()'s File. That File loses
the on-disk path Electron's webUtils.getPathForFile() needs (electron/electron#33647),
which broke drag-and-drop path access from v1.x onward.

Return the File captured synchronously from getAsFile() instead - it preserves the
original File object identity Electron keys on - and only fall back to handle.getFile()
when getAsFile() returned null (e.g. a cross-window drop). The durable handle is still
attached either way, and directory traversal is unaffected.

Closes react-dropzone/react-dropzone#1411.
@rolandjitsu
rolandjitsu merged commit c7807be into main Jul 18, 2026
11 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 4.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant