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

item can overlap calling update() and locked items

Open giantroboticcat opened this issue 3 years ago • 3 comments

Subject of the issue

When using GridStackEvent.update to move an item upwards in the y direction the collision detection allows grid-items to overlap

Your environment

  • Gridstack 5.0 HTML5 Native
  • Chrome Version 100.0.4896.127
  • Windows 10

Steps to reproduce

Press any of the shift up buttons and notice how the moveable object intercepts other locked grid-items. https://jsfiddle.net/e0nstd53/1/

Expected behavior

Item either skips above the locked item (such as the case when shifting down), or the item does not move at all.

Actual behavior

Items overlap

giantroboticcat avatar Apr 29 '22 05:04 giantroboticcat

thanks for the bug report. can you make sure it still happens with latest rev ? (5.0.0) I'm guessing this is only and issue with locked items (which should fail to move).

adumesny avatar Apr 29 '22 15:04 adumesny

Correct it's only an issue with locked items. Unlocked items behave as you would expect.

I can also confirm this issue persists on 5.0.0.

Sorry I didn't realize the fiddle I usurped to make the demo wasn't using latest rev. Here is an updated fiddle pointing at latest rev and behavior remains the same.

https://jsfiddle.net/bhkm95gt/1/

I also want to note that I am currently working around the issue by using the isAreaEmpty api call to check if the update should proceed. It works to prevent the overlap, but it obviously stops any sort of skip over code from executing. As such it simply serves to cover the "item does not move at all" expected behavior... although that is certainly less ideal than having the item skip over to a valid area above the item.

giantroboticcat avatar Apr 29 '22 16:04 giantroboticcat

if you move up by 1 and it has a locked item, it should fail to move and stay put (moving above - you can do that manually by moving enough past 1 to mean ok go before that locked items, but doing similar heuristics (say move by 2 but you really need 3 to clear a locked item) would be much harder to implement...

if you want to donate something, I can probably find some time, but I'm really swamped these days otherwise... you might be able to work around it by checking the item at that location and checking for lock (not just empty)

adumesny avatar Apr 29 '22 18:04 adumesny