Skip to content

Items placed wrong after resizing when using columnOpts.breakpoints #3192

@ocostello

Description

@ocostello

Subject of the issue

When the user resizes a page smaller, hence triggering use of columnsOpts.breakpoints the components usually seem to be positioned correctly, but when the user refreshes the page some of the components are in the wrong place.

Your environment

  • version of gridstack.js - 12.3.3
  • which browser/OS - Chrome + macOS

Steps to reproduce

  • Open viewport of the jsfiddle test square wide, and make the gridstack component wide so all 12 widgets are displayed side-by-side.
  • Make the gridstack component thinner until it hits 6 column breakpoint and changes from a 12x1 grid of widgets to a 6x2 grid. So far all good!
  • Refresh the page, the width of the gridstack component should've remained the same
  • The widgets are now in a weird order, 6 in row 1 and then a new widget in every row, the last column after this

We're using Gridstack.init to load items instead of addWidget, but so is the demo code so that seems like a common usecase.

https://stackblitz.com/edit/gridstack-demo-f2h1wxbm?file=styles.css

Screen.Recording.2025-11-17.at.17.16.24.mov

Expected behavior

I'd expect the page to look the same after a refresh as it did before a refresh - 6 widgets on the first row and 6 widgets on the second row

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions