Opened 8 years ago

Last modified 2 years ago

#13964 new defect

scrollbar activates DnD

Reported by: Adam Peller Owned by: Eugene Lazutkin
Priority: high Milestone: 1.15
Component: DnD Version: 1.7.0b1
Keywords: Cc: Eugene Lazutkin
Blocked By: Blocking:


In the "items" tree in the upper-right hand corner (Apples, Bananas...) click and drag one item in the tree to reorder. See the DnD UI, which will disappear when you're done.

Now click on the scrollbar. Move the mouse back over the tree. You'll see the DnD UI appears again. This only seems to happen if you do a DnD operation first.

Change History (10)

comment:1 Changed 8 years ago by Adam Peller

Component: DijitDnD
Owner: set to Eugene Lazutkin

I can reduce this to a dnd test case:

Take one of the containers (e.g. "source 1") and set overflow:scroll. As before, try a drag operation first, then click on the scrollbar. It seems to pick up the last dragged item. Perhaps there's a reference which should be removed on drop?

comment:2 Changed 7 years ago by bill

See also #13946 and #10585.

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

comment:3 Changed 7 years ago by Adam Peller

link in the description is stale. Try a more recent nightly, or the current one at

comment:4 Changed 7 years ago by kuba

This issue seems to have been around forever. It makes dijit.Tree widget difficult to use for larger data sets, or where the node label can be long thus causing horizontal scroll. In absence of reasonable scroll bar presence, perhaps the minimum change would be to provide a dead zone for dnd in the area where scroll bars may/may not be present.

In previous discussion on #10585 a solution of triggering scroll over the tree node only is also discussed. I like that solution as in my view it aligns well with behaviour of other GUI environments that I've used.

comment:5 Changed 7 years ago by bill

Something like this in the mousedown handler may work too, although it needs to be adjusted for RTL systems where the scrollbar is on the left:

if (evt.offsetX > node.clientWidth) return;

I guess offsetX could be relative to a nested node rather that the node with the scrollbar, so might need to use clientX/clientY instead (and subtract the position of the node).

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

comment:6 Changed 7 years ago by jackmon

I was able to workaround this by using a custom dndSource and in its onMouseDown I do this:

 //Prevent drag/drop from happening when user mouses down on scrollbar
 var isContainer = domClass.contains(e.srcElement, "dojoDndContainerOver");	

Not sure if that's right, but it seems to do the trick for me.

comment:7 Changed 7 years ago by kuba

A variation on the solution above, for dojo 1.7.2 I've modified dijit.tree.dndSource.onMouseDown function so that it returns when triggered from a digitTree element. This way, the drag is only done if you are dragging node(s), but not when dragging a the tree container. Additional code

var cName =;
if(cName.indexOf("dijitTree ") != -1) {

comment:8 Changed 7 years ago by hendrikvanantwerpen

The offsetX/Y parameters seem not available on all browsers. I made a small patch that works for me in recent Firefox and Chrome versions, using dojo.position and clientLeft/Width. In dojo.dnd.Source::_legalMouseDown(e):


   if(!dojo.mouseButtons.isLeft(e)){ return false; }

   // reject when click originated on vertical scrollbar
   var pos = dojo.position(e.currentTarget);
   var left = pos.x+e.currentTarget.clientLeft;
   var right = left+e.currentTarget.clientWidth;
   if ( e.clientX < left || e.clientX > right ){
      return false;

   if(!this.withHandles){ return true; }


comment:9 Changed 3 years ago by dylan

Milestone: tbd1.12

We should either fix this for 1.12, or close as patchwelcome. Given that some earlier efforts were made to try and fix it, I'm reluctant to close it immediately, so will revisit after 1.11 is released.

comment:10 Changed 2 years ago by dylan

Milestone: 1.131.15

Ticket planning... move current 1.13 tickets out to 1.15 to make it easier to move tickets into the 1.13 milestone.

Note: See TracTickets for help on using tickets.