Skip to content

Toggling staticGrid value with the setStatic function doesn't have any impact on the drag in possibility #1761

Closed

Description

@adriguy

Subject of the issue

When initializing a grid with staticGrid: true, it is not possible to drag in a new widget (pretty logical).
However, when toggling this option thanks to the setStatic option, although it is now possible to resize/move the widgets, it is still not possible to drag in new widgets.

Your environment

  • gridstack 4.2.0
  • Chromium 90.0.4430.212

Steps to reproduce

https://codepen.io/adriguy/pen/RwpRzej

JS:

function toggleStatic() {
  const grid = document.querySelector(".grid-stack").gridstack;
  grid.setStatic(!grid.opts.staticGrid);
  console.log("staticGrid new value:", grid.opts.staticGrid);
}

var items = [
  { content: "my first widget" },
  { w: 2, content: "another widget" }
];

const options = {
  cellHeight: 150,
  float: false,
  staticGrid: true,
  dragIn: ".sidebar .grid-stack-item",
  dragInOptions: {
    revert: "invalid",
    scroll: false,
    appendTo: "body",
    helper: "clone"
  },
  acceptWidgets: true
};

var grid = GridStack.init(options);
grid.load(items);

HTML:

<div class="sidebar">
  <div class="grid-stack-item">
    <div class="grid-stack-item-content">Drag me</div>
  </div>
  <div class="grid-stack-item" gs-w="2" gs-h="1" gs-max-w="3">
    <div class="grid-stack-item-content">2x1, max=3</div>
  </div>
  <button onclick="toggleStatic()">Toggle static
</div>
</div>

<div class="over-grid-stack">
  <div class="grid-stack"></div>
</div>

Expected behavior

When toggling the button (staticGrid becomes false), we should be able to drag in new widgets.

Actual behavior

When toggling the button (staticGrid becomes false), it is still impossible to drag in new widgets.

Activity

  1. added a commit that references this issue on May 25, 2021
    3e430d0
  2. adumesny commented on May 25, 2021

    @adumesny
    Member

    fixed in next release - don't forget to contribute if you find this lib useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions