gridstack / gridstack.js

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

Grids With < 12 Columns Will Accept Widgets Greater Than Set Column Size And Resize Them #2726

Closed Xilophinum closed 1 week ago

Xilophinum commented 1 week ago

Subject of the issue

When using grids that are less than 12 columns, and then having widgets with widths greater than the column number, it will accept the widget as long as row variables are correct. It will also resize the widget to the grids max columns, causing the widget to be a new width.

Your environment

Steps to reproduce

https://jsfiddle.net/odtm6x5b/17/

Expected behavior

Respect the column size of the grid being dragged into. If the column size is smaller than the widgets width, reject the widget.

Im not good with PRs (literally have never done one before), but here is what I did to fix the issue. No idea if this would cause issues. But it fixes the issue for me. Under gridstack-engine.ts

image

adumesny commented 1 week ago

so you're saying that dragging a w:2 widget into a 1 column grid should never work ? it depends... you could make a case that it should shrink to fit (which it does), like we do during responsive design... relunctant to force a reject, not clear we need an option either. but that is the right fix for you. You can patch the lib method instead (doc shows how) for your use case (instead of modify lib) https://github.com/gridstack/gridstack.js?tab=readme-ov-file#extend-library

| Thanks for my rotational widgets, I was the sponsor! the name and email doesn't match, but thank you if you work together...