vue3-dragable-grid-layout
vue3-dragable-grid-layout copied to clipboard
Resize loop when a scrollbar appears at responsive breakpoint
After seeing that the original project appears to not be maintained anymore, I decided to migrate to this project. So this issue is a copy of the one I created on the original repository.
Describe the bug
When the window is resized, the component checks its new width and switches layout responsively. If the new layout is talller than the previous one, the height of the grid is increased. A scrollbar may appear on the parent container of the grid.
The scrollbar takes space, therefore reducing the width of the container. If the new width of the container due to the scrollbar width makes the grid switch breakpoint again, we end up in a resize loop.
For example, if our breakpoint is 996px and the scrollbar is 20px wide. If the grid reaches 996px due to a resize, it will switch to the wider breakpoint. The grid items are re-organized and the height of the grid increases. A scrollbar appears and takes space. The grid is now 976px wide (996-20px) and switches back to the previous breakpoint. The scrollbar disappears so the grid expands again and reaches 996px width again. Repeat.
To Reproduce Steps to reproduce the behavior:
- Create a container with
overflow-y: auto
- Create a grid layout with an explicit breakpoint (for example
{ md: 996, sm: 0 }
) inside this container - Define two layouts for the grid. the md layout must be taller than the sm layout.
- Resize the container to make it so the sm layout can be contained by the container but not the md layout
- Resize the width of the container to 996px
- See the resize loop
Expected behavior The breakpoints should be calculated based on the width of the window or of the container, not on the width of the grid. Or maybe add an option to chose if the breakpoints should be based on the window or on the grid.