Opened 7 years ago

Closed 7 years ago

#16427 closed defect (duplicate)

dojo.on with dnd does not work the same on an Android device.

Reported by: Mark Miller Owned by: Mark Miller
Priority: undecided Milestone: tbd
Component: Events Version: 1.8.1
Keywords: Cc:
Blocked By: Blocking:

Description

I've discovered a possible bug. When using dojo.dnd to register Sources and also using dojo.on to register touch.release listeners for the same nodes, there is different behavior on an Android device.

In Firefox/Chrome? the on listener will fire for the node under the mouse (the destination node) but on Android it will fire for the source node. I've been trying to debug but there's no luck.

Here's the html you can use to reproduce. Check the console.

<!DOCTYPE html> <html>

<head>

<meta charset="utf-8"> <script data-dojo-config="async: 1" src="dojo/dojo.js"></script> <style>

li {

padding: 10px;

}

</style>

<script>

require(['dojo/dom-class','dojo/dnd/Source','dojo/domReady!'],function(domClass,Source) {

var left = new Source("left",{accept: item?}); var right = new Source("right",{accept: item?}); left.insertNodes(false,[

{ data: "Item1", type: [ 'item' ] }, { data: "Item2", type: [ 'item' ] }

]); left.forInItems(function(item,id,map){

domClass.add(id,item.type[0]);

});

});

</script>

</head> <body>

<script type="text/javascript">

function leftMouseUp() {

console.info("leftMouseUp");

} function rightMouseUp() {

console.info("rightMouseUp");

} require(

["dojo/dom","dojo/on","dojo/touch","dojo/domReady!"], function(dom,on,touch) {

on(dom.byId("left"),touch.release,leftMouseUp); on(dom.byId("right"),touch.release,rightMouseUp);

}

);

</script> <div style="width:50%;float:left">

<ol id="left" style="height:200px"> </ol>

</div> <div style="width:50%;float:left">

<ol id="right" style="height:200px"> </ol>

</div>

</body>

</html>

Change History (7)

comment:1 Changed 7 years ago by Mark Miller

Should add that I'm testing it on a Samsung Galaxy Tab 2 with Android 4.0.3.

comment:2 Changed 7 years ago by bill

Owner: changed from Kris Zyp to Mark Miller
Status: newpending

For your test case, are you saying to touch one button, slide your finger to the other button, and then remove your finger?

I just checked dojo/touch.js, and we don't have any special code for normalizing touch.release on touch devices, so it will default to the standard for how the native "touchend" event works: to fire the event on the source node.

Technically dojo/touch is working according to its spec -- listening to mouseup or touchend -- but I agree the behavior is not in the spirit of dojo/touch, which is to normalize behavior between mouse and touch events.

Are you really saying this behavior only happens when using touch.release in conjunction with DnD? It looks like it will happen all the time.

BTW it's a bit better for the future if you use the "attach file" button to attach test cases.

Last edited 7 years ago by bill (previous) (diff)

comment:3 Changed 7 years ago by Mark Miller

Status: pendingnew

For your first question, the answer is yes. I'm dragging items from one <ol> to the other.

For example if I drag an item from left to right, in firefox/chrome the rightmouseup listener fires, on Android the leftmouseup listener fires.

For the second question, no I'm not saying it ONLY happens with dnd and on. I just tried yanking dnd out but I lose the preventDefault handling and don't have time right now to figure out how to add it back.

Sorry about the copy/paste.

comment:4 Changed 7 years ago by bill

OK, I see. For some reason I thought those were <ol>'s were buttons. I was confused.

So, besides touch.release not working as you expected, is DnD broken somehow? Because I notice that both dojo/dnd and the DnD code in Tree are using touch.release.

comment:5 Changed 7 years ago by Mark Miller

DnD is working fine as far as I can tell.

comment:6 Changed 7 years ago by bill

Yeah.... a little while after I asked that question I realized that most of the uses of touch.release within dojo are on the document object itself, rather than a node within the document, so there's no issue of which node the event is fired on. It looks like the one case where the listener is on a different node is for dojo/dnd/Moveable, but in that case the finger goes down and up on the same node because the node moves along with the finger.

comment:7 Changed 7 years ago by bill

Resolution: duplicate
Status: newclosed

After all this discussion I decided to reduce the information down to a new ticket.

Duplicate of #16438.

Last edited 7 years ago by bill (previous) (diff)
Note: See TracTickets for help on using tickets.