Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When pasting files in Safari the DataTransfer doesn't include files #4465

Open
wereHamster opened this issue Aug 23, 2021 · 2 comments
Open
Labels

Comments

@wereHamster
Copy link
Contributor

Description

When pasting files in Safari (eg. select a file in Finder, copy, focus editor, paste), the DataTransfer object doesn't include the selected files (dataTransfer.files.length is 0). The issue seems to be that Safari doesn't expose files in the beforeinput event (which is what Slate uses).

Sandbox

This codesandbox allows you to inspect the payload of the paste and beforeinput events: https://codesandbox.io/s/paste-vs-beforeinput-cjniw?file=/index.html

Safari
image

Chrome
image

Expectation
When pasting files, the files are available under the DataTransfer .files list

Environment

  • Slate Version: 0.63.0
  • Browser: Safari 14.1.2 and Safari Technology Preview 130 (Safari 15.0, WebKit 16612.1.26.1.5)
@dylans
Copy link
Collaborator

dylans commented Aug 24, 2021

@wereHamster thanks for including the links (I was going to respond with something similar).

There is talk that the newer async Clipboard API should solve this issue, but I've not tried it yet and slate-react doesn't use it yet. It does also have obstacles requiring user approval for reading the copy buffer (which is why I believe that Safari should work with the newer API for files but have chosen to not support files with the older API). I do think at some point we need to make the switch as my guess is that the existing approach we currently take will get deprecated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants