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

Platform: accessing DataTransferItems during external drag (before drop) #149

Open
psychedelicious opened this issue Nov 7, 2024 · 0 comments

Comments

@psychedelicious
Copy link

The docs say:

Due to the web platform drag and drop security model, you can know what "types" are being dragging during a drag (eg "text/plain"), but you can only see what data is being dragged (exposed through .items) during a successful "drop" event (onDrop()).

https://atlassian.design/components/pragmatic-drag-and-drop/core-package/adapters/external/about#monitor-for-external

However, it looks like I can access the items using the native dnd API as seen in this demo: https://stackblitz.com/edit/vitejs-vite-cgmywj?file=src%2FApp.tsx

I was confused about this until I realized I only get the items on Chrome and FF - not Safari.

  • Who is implementing the spec correctly - Chrome & FF or Safari?
  • If Chrome & FF are adhering to the spec, can we expect pdnd to expose items during drag events once Safari catches up?
  • Are there any suggested workarounds to provide user feedback as soon as a drag starts? I'd like to be able to, for example, enable some drop targets only when the drag has image files.

Thanks!


Some context, in case this helps anyone else who is migrating to pdnd and confused by this.

I was porting from react-dropzone. You provide file constraints to the useDropzone hook, and it uses those for validation when the drag starts. As I migrated the constraints to pdnd, I was puzzled when I didn't get any items to validate in my canDrop callback. I double-checked the native events and saw the items.

Like native events, react-dropzone provides items during drag on Chrome & FF but not Safari. On Safari, it handles any drag as invalid. I had apparently never tested our react-dropzone dnd implementation with Safari until now.

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

No branches or pull requests

1 participant