Opened 5 years ago

Last modified 2 years ago

#17273 assigned defect

[patch][cla] dojo/dnd/Target containing multiple drop targets unable to drop.

Reported by: haysmark Owned by: dylan
Priority: undecided Milestone: 1.15
Component: DnD Version: 1.9.1
Keywords: Cc:
Blocked By: Blocking:

Description

See the attached test case. Drag the TIE Fighter from the left to the right outer target. The cursor turns green. With the mouse still held down, drag to one of the inner targets. The cursor goes red.

But if you try to drag back to the outer target, the cursor STAYS red. It should turn green.

Attachments (1)

test_dnd2.html (3.8 KB) - added by haysmark 5 years ago.
Test case.

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by haysmark

Attachment: test_dnd2.html added

Test case.

comment:1 Changed 5 years ago by ben hockey

nested targets aren't supported. i am very painfully aware of this because i'm in the middle of a couple of weeks on a customer project writing customized Container, Select and Source modules from scratch to enable this (amongst other things). the code is heavily customized to the customer's needs so unfortunately i won't be contributing anything from it. i looked at the dijit/Tree dnd as inspiration because it allows you to drag tree nodes in a hierarchical fashion which is sort of what nested targets would be trying to achieve.

comment:2 Changed 5 years ago by bill

Should this be closed as a dup of #5859? There's a patch there too, although I haven't looked at it.

comment:3 Changed 5 years ago by ben hockey

the patch on #5859 could be improved - there's really no need for a flag for nested targets and it just looks messy.

the logic that needs to be applied is described like this:

  • when the mouse is over the nested source/target, a mouseover event will bubble from the inner source to the outer source. the inner source will first call manager.overSource(this) (setting manager.target to the inner source). then the mouseover event will reach the outer source at which point it should ignore it if the node associated with manager.target is a descendant node otherwise it can call manager.overSource(this)
  • when the mouse leaves a source, the source should call manager.outSource(this); to unset manager.target. if the mouse was leaving the inner target, then it will now be over the outer target which will then cause a mouseover event to apply the logic in the previous bullet point - there will be no manager.target so then the outer source can register itself as the target via manager.overSource(this)

if you're lucky, this is all the relevant code that needs to be changed in dojo/dnd/Source:

                onOverEvent: function () {
                        Source.superclass.onOverEvent.call(this);
                        var manager = Manager.manager(),
                                target = manager.target || {},
                                node = target.node;

                        // we might be nested, which means a child container may have got this enter event first
                        // and set itself.  only tell the manager that the mouse is over us if the current
                        // target is not a descendant of ours
                        if (!(node && dom.isDescendant(node, this.node))) {
                                manager.overSource(this);
                                if (this.isDragging && this.targetState !== 'Disabled') {
                                        this.onDraggingOver();
                                }
                        }
                },

i haven't tested it but i *think* that's all that's relevant to this - i have lots of other features so my code barely looks like dojo/dnd anymore and i only have to support "modern" browsers so maybe i've relied on something that won't work cross-browser.

comment:4 Changed 3 years ago by dylan

Milestone: tbd1.12
Owner: set to dylan
Status: newassigned
Summary: dojo/dnd/Target containing multiple drop targets unable to drop.[patch][cla] dojo/dnd/Target containing multiple drop targets unable to drop.

comment:5 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.