Skip to content

destroy(false) requires staticGrid: false to reinitialize resize/drag properly #1764

Closed

Description

@periapsistech

Subject of the issue

When destroying a grid using grid.destroy(false) you must specify the staticGrid option during reinitialization. Calling destroy(false) should not overwrite the grid's options and use the defaults as depicted in the documentation.

Your environment

  • gridstack.js v4.2.3, HTML5
  • Chrome, Windows 10

Steps to reproduce

  1. Initialize grid using default constructor (or anything really)
  2. Destroy the grid using grid.destroy(false)
  3. Reinitialize the grid using the default constructor (which assumes staticGrid: false)
  4. Drag/Resize will no longer work
  5. Execute grid.setStatic(false), drag/resize works again

I was able to reproduce this using the 'demo1' example as well.

See fiddle:
https://jsfiddle.net/u35pmjLd/

Expected behavior

Calling destroy(false) then init() should keep the default options/functionality. In this case, staticGrid should be set to false. This will continue to allow grid items to be resizable and draggable.

Actual behavior

After destroying a grid and reinitializing with the default constructor, the grid becomes static and prevents drag/resize actions on the grid items requiring either an API call to grid.setStatic(false) or adding a redundant staticGrid: false to the initializer options.

Happy to supply more info!

P.S. This was supposedly resolved in this PR:
#1209

Activity

  1. adumesny commented on May 25, 2021

    @adumesny
    Member

    thank you. it's busted in JQ as well even though 1209 did solve it back then (when there wasn't an h5 version).

  2. periapsistech commented on May 25, 2021

    @periapsistech
    Author

    @adumesny Well that would explain it! :)

  3. added a commit that references this issue on May 29, 2021
    f7b774e
  4. adumesny commented on May 29, 2021

    @adumesny
    Member

    fixed in next release. if you find this lib useful, don't forget to donate!

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