Opened 5 years ago

Last modified 3 years ago

#10111 open bug

Over callback of parent with greedy child does not trigger after drop on child.

Reported by: mmounts Owned by: mmounts
Priority: minor Milestone: none
Component: ui.droppable Version: 1.10.4
Keywords: Cc:
Blocked by: Blocking:

Description

When you have nested droppable targets that have 'greedy' set to true, the parent will stop receiving 'isOver' triggers after an element is dropped onto one of its children. This is because 'this.greedyChild' is set on the parent when the draggable component is put over the child, but it is not set back to 'false' when the element is dropped onto the child. Because of this, the parent will be ignored by further drag events until something triggers 'isOut' on one of its children. There needs to be a line that sets 'greedyChild' on a parent element back to false after an item has been dropped onto the child as well as when the item is moved out of the child.

//Run through all droppables and check their positions based on specific tolerance options
		$.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {

			if(this.options.disabled || this.greedyChild || !this.visible) {
				return;
			}
...

			if (this.options.greedy) {
				// find droppable parents with same scope
				scope = this.options.scope;
				parent = this.element.parents(":data(ui-droppable)").filter(function () {
					return $.data(this, "ui-droppable").options.scope === scope;
				});

				if (parent.length) {
					parentInstance = $.data(parent[0], "ui-droppable");
					parentInstance.greedyChild = (c === "isover");
				}
			}
...

Change History (10)

comment:1 Changed 5 years ago by tj.vantoll

Owner: set to mmounts
Status: newpending

Hi mmounts,

Thanks for taking the time to contribute to jQuery UI. We need a reduced test case that shows the behavior in order to look into this. You can use this as a starting point: http://jsfiddle.net/tj_vantoll/8RtqV/.

Also, please check whether this is a duplicate of #9389 or #9766.

Thanks.

comment:2 Changed 5 years ago by mmounts

Status: pendingnew

I do not think that the bugs are related to mine. Both of those are related to behavior when you exit a child element, while the bug I am reporting is caused by letting go of the draggable without leaving the element. Here is a quick example:

http://jsfiddle.net/KHmP2/

Steps to reproduce:

  1. Drag blue box up to the green child element (child should be yellow, parent is red)
  2. Let go of the draggable blue box without leaving the child (child is green, parent is red)
  3. Drag blue box up into parent without intersecting the child element (parend is red, should be yellow)

To reset the bug and start getting the correct behavior again (parent turns yellow on hover), drag blue box over the child again and then drag it back to the parent. This is because the setting causing the bug is only reset on the child 'out' handler, not on 'drop'.

I will be working on a fix for this and work on getting a pull request soon if it is approved quickly.

comment:3 Changed 5 years ago by tj.vantoll

Status: newopen

comment:4 Changed 5 years ago by aloinu

I have exactly the same problem. Is it going to be fixed soon? Is there any workaround in the meantime? Thanks in advance.

comment:5 Changed 5 years ago by mmounts

Here is the fix that I am using, and have in a PR for the library. It has not been responded to yet, but you can use it locally if you still need something:

https://github.com/jquery/jquery-ui/pull/1273

comment:6 in reply to:  5 Changed 5 years ago by aloinu

It works perfectly! Thanks a lot! Hope the PR is included in next release...

Last edited 5 years ago by aloinu (previous) (diff)

comment:7 Changed 5 years ago by sgerace

PR worked for me as well.

comment:8 Changed 3 years ago by Deepankar Jain

I have a slightly different scenario in which over propagation to the parent container doesn't work. It could be that it has the same root cause. Therefore, I've logged the following defect.

https://github.com/jquery/jquery/issues/3032

comment:9 Changed 3 years ago by Deepankar Jain

Correction, here's the new issue I raised, #14943.

Last edited 3 years ago by Ryan J Ollos (previous) (diff)

comment:10 Changed 3 years ago by raghu-nv

https://github.com/jquery/jquery-ui/pull/1273

Works Perfectly for me Thank you

Note: See TracTickets for help on using tickets.