Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.0 HTML5 drag'n'drop initial GridStack.enable() Error #1505

Closed
infime opened this issue Dec 1, 2020 · 4 comments · Fixed by #1506
Closed

3.0.0 HTML5 drag'n'drop initial GridStack.enable() Error #1505

infime opened this issue Dec 1, 2020 · 4 comments · Fixed by #1506

Comments

@infime
Copy link
Contributor

infime commented Dec 1, 2020

Subject of the issue

Calling enable() with the new native drag'n'drop throws an Error.

Your environment

  • v3.0.0 HTML5
  • Chrome 86.0.4240.111

Steps to reproduce

Will follow up with a reproduction

Expected behavior

Calling enable should not throw an error

Actual behavior

Stack trace

gridstack-dd-native.js?9be6:33 Uncaught (in promise) TypeError: Cannot read property 'enable' of undefined
    at eval (gridstack-dd-native.js?9be6:33)
    at Array.forEach (<anonymous>)
    at GridStackDDNative.resizable (gridstack-dd-native.js?9be6:31)
    at eval (gridstack-dd.js?a66a:484)
    at Array.forEach (<anonymous>)
    at GridStack.gridstack_1.GridStack.resizable (gridstack-dd.js?a66a:473)
    at eval (gridstack.js?7e36:558)
    at Array.forEach (<anonymous>)
    at GridStack.enableResize (gridstack.js?7e36:558)
    at GridStack.enable (gridstack.js?7e36:527)
@adumesny
Copy link
Member

adumesny commented Dec 2, 2020

thanks for the effort! let find a reproduceable case and I will fix it!

looks like you are calling enable on a static grid maybe ??? (no DD created and jumping to enabling on null DD)

  public enableResize(doEnable: boolean, includeNewWidgets = true): GridStack {
    if (doEnable && this.opts.staticGrid) { return this; } // can't size a static grid!

should prevent resize() from being called on static grid, yet if not static it should NOT be null. So curious how you got there ?
did you mod the grid .staticGrid option directly ? big no no :)
because calling setStatic(false) would create DD as tested...

https://gridstackjs.com/demo/static.html is exactly to test this BUT it uses setStatic(true/false) which is more permanent version of enable()/disable(). I need to refresh my memory why we have both method
Update: added more doc why we have both - subtle difference.

@infime
Copy link
Contributor Author

infime commented Dec 2, 2020

Nope no static grid involved, I think it's potentially related to using load(). I'll get a reproduction going.

@infime
Copy link
Contributor Author

infime commented Dec 2, 2020

https://jsfiddle.net/anzojxum/19/ reproduces the issue. It's being triggered when calling enableResize when at least one of the widgets is locked

@adumesny
Copy link
Member

adumesny commented Dec 2, 2020

ha, that makes sense... taking a look.

adumesny added a commit to adumesny/gridstack.js that referenced this issue Dec 2, 2020
* fix for gridstack#1505
* make sure we don't call  movable()/resizable() on locked items to start with
* prevent staticGrid from having enable/disable state changes as well
* better doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants