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

Simplifying the flow. Observing 'mousemove' after 'dragstart' to trigger endDrag instead of depending on browser to trigger 'dragend' #801

Merged
merged 3 commits into from Jul 11, 2017

Conversation

hunterbmt
Copy link
Contributor

@hunterbmt hunterbmt commented Jun 19, 2017

Simplifying the flow, so can prevent the error to occurs when the browser fails to trigger 'dragend' or 'drop'. I.e #789
Now we depend only on 'mousemove' triggering after 'dragstart' to determine that the dragging is ended.

@darthtrevino
Copy link
Member

Hey @hunterbmt, thanks for the PR, sorry for not getting to it for a while. I'll give this a deeper look later tonight

@darthtrevino darthtrevino merged commit 8a3eb74 into react-dnd:master Jul 11, 2017
@hunterbmt
Copy link
Contributor Author

@DanielKoehler thanks for taking care this one.

@darthtrevino
Copy link
Member

maui-in-moana-what-can-i-say-except-youre-welcome

@@ -228,12 +225,7 @@ export default class HTML5Backend {
this.currentNativeSource = null;
}

endDragIfSourceWasRemovedFromDOM() {
const node = this.currentDragSourceNode;
if (document.body.contains(node)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this check is gone now? after seeing #789 i don't see any example that shows the problem.. the issue even says that the react-dnd example works normally in chrome 59

Copy link

@bjrmatos bjrmatos Jul 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please @darthtrevino consider revert this change, it is changing the behaviour of react-dnd..

  • for example if i drag a component and drop it outside of a valid drop area and i don't move the mouse, the preview is hanging until i move the mouse (because this PR changed from using the native dragend event to mousemove event).

before this PR (endDrag received inmediatly):

dragging before

with this PR (endDrag not received until i move the mouse):

dragging now

  • before this PR if i start dragging something and press the "ESC" key the dragging is cancelled and then the endDrag method is called normally, with this PR that behaviour is gone

  • before this PR the endDrag method was always called when the preview image (or ghost preview) actually returns to the original location where the dragging started, but now this is gone completly and the timing of the event is different. (with the additionally thing that we now need to move the mouse to get the endDrag method called)

since this is a HTML5 drag and drop implementation i think it is completly reasonable that we need to use the html5 drag and drop events, the browser handles a lot of cases automatically.. we are just getting in troubles by eliminating listening the dragend event.

if there is a problem with chrome 59 (like this issue describes) we need to focus on reproduce the real problem instead of adding a workaround that changes the behaviour of everything. @hunterbmt can you please provide a minimal example where react-dnd fails with the dragend event in Chrome 59? i don't have any problem with Chrome 59, but i'm curious and willing to help to identify your real issue, if there is a problem it should be reproducible with a minimal example.

@bjrmatos
Copy link

bjrmatos commented Jul 24, 2017

@darthtrevino @theTechie i made some comments about this change, please let me know your feedback. thnks

@bjrmatos
Copy link

and cc @hunterbmt just in case you don't get the notification for the mention in the review comment.

@hunterbmt
Copy link
Contributor Author

@bjrmatos I agreed with you about the behavior changes in the PR. I didn't think about all the cases when submitting the PR.
Since we alway check if we have currentSourceNode before trigger 'endDrag', I think having 'dragend' and 'drop' (for sourceNode removed from DOM cases) to trigger 'endDrag' beside 'mousemove' after 'dragstart' to trigger 'endDrag' won't hurt at all while covering all the case you mention.
I cannot give you the example for Chrome 59 issues since it's a production code and it's quite a big application even though the logic at DnD component is quite straightforward. The code works normal on FF, IE, Safari and Chrome 58 but not Chrome 59 since it won't trigger 'dragend' event after 'drop' at all. In some cases, it won't even trigger 'drop' when I drag item into un-dropable area. But according to couple comments on the issues, I don't think that I face that issue alone.
I will create another PR to fix the issue without impact current behavior of react dnd. Sorry for a bad PR.
In the meantime, please help me to revert the PR first to avoid any accidentally release.

Regards,

@darthtrevino
Copy link
Member

darthtrevino commented Jul 25, 2017 via email

@bjrmatos
Copy link

thnks @darthtrevino

I think having 'dragend' and 'drop' (for sourceNode removed from DOM cases) to trigger 'endDrag' beside 'mousemove' after 'dragstart' to trigger 'endDrag' won't hurt at all while covering all the case you mention.

let's see.. firing endDrag by listening dragend allows to handle a lot of functionality for free, so if you can make the change that you have in mind i'm willing to help to test that it does not change the current behaviour.

I cannot give you the example for Chrome 59 issues since it's a production code and it's quite a big application even though the logic at DnD component is quite straightforward. The code works normal on FF, IE, Safari and Chrome 58 but not Chrome 59 since it won't trigger 'dragend' event after 'drop' at all. In some cases, it won't even trigger 'drop' when I drag item into un-dropable area. But according to couple comments on the issues, I don't think that I face that issue alone.

i understand that point but every issue needs at least a reproducible case, so maintainers or other people can help to verify the problem and think in the better solution, if there is no reproducible case the issue turns into something that maintainers or users of the library can not trust at 100% because there is no proof of the problem described. i understand that your codebase is big but trying to isolate the issue and removing some not relevant parts of your code to create a reproducible case should be not very hard and i think it is the only way to identify or verify the real issue so everyone can be happy.

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

Successfully merging this pull request may close these issues.

None yet

3 participants