-
Notifications
You must be signed in to change notification settings - Fork 377
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
HTML 5 Drag and Drop: Impossible to disallow a drop operation in GWT #9989
Comments
According to the comment, it looks like this was specifically (at the time, 11 years ago) to prevent a bug where while dragging something, text would be selected. I'm assuming that is no longer true, so it should be trivial to remove that line and comment (and test to confirm). Without that line, this is just standard |
I don't really understand that comment. The HTML5 DnD spec says that the browser should disable text selection if an element is marked with However, GWT does Anyways, yes the code should be deleted in GWT because |
I can't speak confidently here without an 11 year old browser up and running, but did the spec say that 11+ years ago? Did all browsers consistently implement it that way? I'm guessing not. If as you say (I have done no testing here) this is entirely unusable for modern browsers, there should be no harm in fixing it, even destructively. Anyone interrupted by this seem to have a simple workaround - put a preventDefault in their event handlers. |
This funny blog article of 2009 indicates that the spec was the same back in the days. You had to prevent the default action if you want to do a drop. If you don't no drop event is triggered and the drag operation is canceled. |
What happens if you disable selection itself (not by preventing the selection event), that way the selection event never happen, and maybe only the drag event happens giving you a chance to prevent it.? https://www.w3schools.com/howto/howto_css_disable_text_selection.asp
|
@mP1 I think you mixed something. You can devide all DnD events into two groups Source element: Without any DnD if you click and hold the mouse button and then move the mouse you select text on the page. That is why the spec says that draggable elements should automatically disallow text selection. Otherwise you select text instead of triggering The issue here is that GWT calls I think HTML5 DnD was badly implemented in browsers and complex to understand 10 years ago. So maybe that code and comment were added by accident. Even 10 years ago the spec states that in order to control wether or not dropping on an element is allowed you have to either prevent or not prevent the default action of |
GWT version: HEAD
Browser (with version): any
Operating System: any
Description
To tell the browser that a future drop operation is allowed on an element/dropzone you have to call
DragOverEvent.preventDefault()
. If you DO NOT call it a drop operation on that element/dropzone results in a canceled drop operation. In that case the dragged element receives adragend
event withdropEffect = none
See: https://jsfiddle.net/gdtja9y7/2/
In GWT all HTML 5 Drag and Drop events are registered using
addBitlessDomHandler
. InDOMImplStandard.getBitlessEventDispatchers()
GWT adds special handling fordragenter
anddragover
events. For both events GWT itself already callsevent.preventDefault()
before calling back to user code. So it is currently impossible in GWT to disallow a drop operation.Known workarounds
Use a helper class to manage event handlers using elemental2
The text was updated successfully, but these errors were encountered: