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

only allow specific object to be dropped #157

Open
pc386 opened this issue Apr 17, 2019 · 2 comments
Open

only allow specific object to be dropped #157

pc386 opened this issue Apr 17, 2019 · 2 comments

Comments

@pc386
Copy link

pc386 commented Apr 17, 2019

Right now a user can drop anything into draggable-object-target, for example text or an image. Is there a way to check for this? So that only the things I allow can be dropped?

edit: I found an easy solution to my problem. I defined a property which is changed by dragStartHook/dragEndHook. And then I encapsuled my drop target in an if with the property, so only when I start dragging my object it actually enables the drop field

@nruth
Copy link
Contributor

nruth commented Aug 26, 2020

The trouble is with https://github.com/mharris717/ember-drag-drop/blame/a58318b39d9929d1438833fac87d057eb0529216/app/models/obj-hash.js#L24

If you select a few words of text from somewhere on the page on a Mac you're able to drag it into other apps and so on. If you drop it into the dropzone provided by this addon it triggers the above code with the selected text as the key, and throws the no obj for key string (not an Error, which makes debugging harder – #173).

My suggestion here is to change the default behaviour from throw-a-string to halt execution. Maybe just change the thrown string to a custom error object and catch it higher up.

This would be nice, as currently Bugsnag reports a new issue for every unexpected item dragged into the dropzone.

@miguelcobain
Copy link

This is an issue for us as well. I was expecting that only <DraggableObject>s could be dragged into <DraggableObjectTarget>s.

Perhaps we could use detect some special data in the DataTransfer to validate the event on the DraggableObjectTarget component.

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

3 participants