gridstack.js icon indicating copy to clipboard operation
gridstack.js copied to clipboard

Adding widget to nested grid: Cannot set property 'isOutOfGrid' of undefined

Open ronvanpol opened this issue 6 years ago • 4 comments

In the situation where you have nested grid where both the parent grid as well as the nested grid accept widgets, adding a widget to the nest grid will result in a javascript error: Cannot set property 'isOutOfGrid' of undefined. It seems that both grids try to handle adding the new widget, while only one is able to accept the widget.

gridstack-error

I have prepared a jsfiddle: https://jsfiddle.net/ncfyau6j/1/

My temp solution was to alter the gridstack.js code. I have added the following check at the start of the function "onDrag":

    if (!draggingElement.is(self.opts.acceptWidgets)) return;

A similar check was added to the event handlers for "drop", "dropover" and "dropout":

    if (!$(ui.draggable).is(self.opts.acceptWidgets)) return;

ronvanpol avatar Feb 11 '20 11:02 ronvanpol

thank you for reporting and fixing it. keep in mind that acceptWidgets can also be true|false|string so you will have to check being a string before checking the class match.

Do you mind doing a pull request ?

I will need to revert my last changes for jquery and move that into a branch (I have a lot of local work for 1.0.0 release with breaking changes I need to put in that branch as well) as I should release a 0.6.4 before with your fixes. I'll be doing that this weekend.

adumesny avatar Feb 11 '20 16:02 adumesny

I have created a pull request. First time I've done that, so I hope that it's ok what I did.

ronvanpol avatar Feb 14 '20 13:02 ronvanpol

I just created a new PR against the develop branche. Hopefully everything is ok this time.

ronvanpol avatar Feb 16 '20 20:02 ronvanpol

fixed in the next release - thanks for reporting and code suggestion!

adumesny avatar Feb 17 '20 02:02 adumesny