gridstack / gridstack.js

Build interactive dashboards in minutes.
https://gridstackjs.com
MIT License
6.66k stars 1.28k forks source link

Gridstack makes the whole component draggable if the custom drag handle is not found at init time #2790

Open BrannJoly opened 2 weeks ago

BrannJoly commented 2 weeks ago

Subject of the issue

when setting a custom drag target with handle: '.custom-draggable-class', if GridStack is initialized before the div with the custom drag handle is rendered, GridStack defaults to making the whole component draggable.

Your environment

Steps to reproduce

See example here posted in this SO question

Expected behavior

Gristack should respect the custom drag handle. If there's no drag handle matching the custom class, the item should not be draggable at all.

adumesny commented 2 weeks ago

yes and no. I could see it go either way... I guess if I cna detect a custom class vs the default one then I cold make the case to avoid dragging if not found as that would be a way for user to say noMove using classes...

BrannJoly commented 2 weeks ago

let me elaborate on my use case : I'm using GridStack to display a list of plotly charts, which uses drag n droping a lot (to zoom, select, etc). So it's very important for me that the whole component is not draggable! It almost always work, but from time to time there must be a race condition somewhere and GridStack initializes before my widgets have been rendered.

When that happens, the whole page must be reloaded.

There's no easy way to fix that problem.

On the other hand, if the user provides a custom class that doesn't exist, I would say it's on him to fix that bug (and it's very easy to fix!)

adumesny commented 1 week ago

Don’t init gridstack until your content is (or div you care) is fully loaded. Not being able to drag is broken as well. Not going to special case your instance…