Skip to content
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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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