Skip to content

fix: resolve the wrong actual dragging item which drag from outside#760

Open
JoeyFan wants to merge 1 commit intojbaysolutions:masterfrom
JoeyFan:joey-outsideItemDragFix
Open

fix: resolve the wrong actual dragging item which drag from outside#760
JoeyFan wants to merge 1 commit intojbaysolutions:masterfrom
JoeyFan:joey-outsideItemDragFix

Conversation

@JoeyFan
Copy link

@JoeyFan JoeyFan commented Jun 13, 2023

Situation:

When I use the feature of dragging item from outside, I find the dragging item can't place in some specific position.

After researching, I found that the grid-item I got by the below codes is another existing grid-item.
let index = this.layout.findIndex(item => item.i === 'drop');
let el = this.$refs.gridlayout.$children[index];
And it leads to the wrong result of calcXY() which based on w and h of the unexpected grid-item.

Root case:

The reason is mismatching between layout sort and $refs.gridlayout.$children sort. So we may get unexpected gird-item by using index of layout.
Refer: https://v2.vuejs.org/v2/api/index.html#vm-children

Solution:

Instead of layout, get grid-item by $refs.gridlayout.$children directly. Like below:
let el = this.$refs.gridlayout.$children.find(el => el.i === 'drop' && !el.$el.classList.contains('vue-grid-placeholder'))
Ps: i of vue-grid-placeholder also is 'drop'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant