-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix quickly drag elements between nested blocks #2573
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
Conversation
| } else if (node._isExternal) { | ||
| // item came from outside (like a toolbar) so nuke any node info | ||
| delete node.el; | ||
| delete el.gridstackNode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't make sense to delete one and not the other... will have to debug the code for that particular case and make sure it doesn't break other cases..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I noticed errors in the console and problems with blocks not being deleted after dragging. Restored this function.
src/gridstack.ts
Outdated
|
|
||
| // if the item came from another grid, make a copy and save the original info in case we go back there | ||
| if (node.grid && node.grid !== this) { | ||
| if (node.grid !== this) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still doesn't feel right to me without debuging the issue - if node doesn't have grid, we go through that logic which doesn't feel right...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you. Now it seems to me that the problem is not in this place at all, but in calling the mouseEnter event in mouseOver. If you comment on this line as a definition of the source of the problem, then everything works correctly - https://github.com/gridstack/gridstack.js/blob/master/src/dd-droppable.ts#L135
|
Redid PR. I discovered a bug of redundant event calling. When the "mouseenter" event was called, the "mouseleave" event was called inside that event. That is, they cleared the previous location of the block and showed a new one. The "mouseleave" event contains the logic for inserting a location into the parent (when we drag the block up into the parent). So, we got a situation where we dragged a field to a child, and the “mouseenter” event was triggered, in turn, “mouseleave” was called, and then “mouseenter” was called. Removed the redundant "mouseenter" step specifically for the program call (the behavior when moving the mouse was preserved). Sorry for my English, I use google translate. |
| this.triggerEvent('dropout', ev); | ||
|
|
||
| if (DDManager.dropElement === this) { | ||
| if (!external && DDManager.dropElement === this) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DDManager.dropElement === this can be removed since on line 113
|
|
||
| if (DDManager.dropElement === this) { | ||
| if (!external && DDManager.dropElement === this) { | ||
| delete DDManager.dropElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should still happen. move to line 114.
rename the var fromParent and instead the next comment should be:
// if we're still over a parent droppable, send it an enter as we don't get one from leaving nested children if it's not already calling us
if (!fromParent) {
let parentDrop: DDDroppable;
let parent: DDElementHost = this.el.parentElement;
....
Description
If you quickly drag elements between nested blocks, duplicates of the same element appear. fix #2560