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

RemoveWidget() doesn't also trigger change events when it should

Open ronvanpol opened this issue 6 years ago • 5 comments

The function RemoveWidget should trigger change events in case that other nodes are changed. For example take the simple case where one has a simple grid containing to adjacing nodes 1 and 2. When node 1 is removed by using the RemoveWidget function, node 2 moves to the place of node 1. This is a change for node 2 and as such it should trigger the change event.

I see in the code that the triggering of this change event is commented out in several places. Why was the decision made not to trigger the change event anymore and for what reason?

ronvanpol avatar Feb 10 '20 14:02 ronvanpol

@ronvanpol do you have an example where the change event doesn't get called when it should ?

I commented some of the change events code because it was calling it when adding/removing a node that had NO OTHER changes to siblings, so only when x,y,w,h is changed should it now trigger (still does call it more often than absolutely necessary but tons better than before, especially when loading 5 widgets we used to get called 5 times with an ever increasing number).

if you run https://gridstackjs.com/demo/two.html and open the console you will see that removing a node in the float=false grid that causes re-ordering WILL call remove+change, in the float=true, just remove.

Please re-open if you can provide a test. use the default template https://jsfiddle.net/adumesny/jqhkry7g. thank you!

adumesny avatar Feb 10 '20 15:02 adumesny

This bug seems to be related to nested grids. I have prepared a jsfiddle. Click on nested items "1" or "2" and the log will only show the removed events and no change events.

https://jsfiddle.net/a7bo92vn/

ronvanpol avatar Feb 10 '20 16:02 ronvanpol

thanks, I can see the issue now. will take a look.

adumesny avatar Feb 10 '20 17:02 adumesny

turns out you don't need nested grid, this simpler example shows the issue as well https://jsfiddle.net/adumesny/znqx4dmr/

adumesny avatar Feb 10 '20 18:02 adumesny

fixed in next release 0.6.4

adumesny avatar Feb 16 '20 02:02 adumesny