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

Locked widgets cannot be moved by the user #1767

Closed
ztessema opened this issue May 27, 2021 · 5 comments · Fixed by #1768
Closed

Locked widgets cannot be moved by the user #1767

ztessema opened this issue May 27, 2021 · 5 comments · Fixed by #1768
Labels

Comments

@ztessema
Copy link

Subject of the issue

Locked widget cannot be moved by the user

Your environment

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

Steps to reproduce

Widget is locked by using the 'locked' property on the gridstackNode:
widget.gridstackNode.locked = true;

Expected behavior

The widget shouldn't be able to be moved due to another widgets being dragged or resized.
The widget can still be dragged or resized by the user.

Actual behavior

The widget shouldn't be able to be moved due to another widgets being dragged or resized.
The widget cannot still be dragged or resized by the user.

@adumesny
Copy link
Member

first of all you should not set locked property directly (internal) but make the api call update(widget, {locked:true}) as there is more to it than setting the flag.

second, locked = noMove (user) + noSize (user) + can't be moved by collision constrain by another widget by design. that is the expected behavior.

@ztessema
Copy link
Author

Thank you for the information. I will use the update function. However I am still confused on the expected behavior of a 'locked' widget. According to the API:

locked - means another widget wouldn't be able to move it during dragging or resizing. The widget can still be dragged or resized by the user. You need to add noResize and noMove attributes to completely lock the widget.
(https://github.com/gridstack/gridstack.js/tree/master/doc#item-options)

so shouldnt a locked widget be able to be moved/resized by the user?

@ztessema
Copy link
Author

ztessema commented May 27, 2021

More generally, how would I acheieve the behaviour of preventing the widget from being moved by the move/resize of other widgets?

@adumesny adumesny reopened this May 27, 2021
@adumesny
Copy link
Member

adumesny commented May 27, 2021

I stand corrected. in v0.5 (the furthers I went back that I worked on) locked can still be dragged by the user.
this broke in v1.1.1 (ok in v1.1.0) as I assumed locked meant no move by user either.

not sure what the use case is for... weird that items will not get pushed out but user can still manually do it.

adumesny added a commit to adumesny/gridstack.js that referenced this issue May 29, 2021
* fix gridstack#1767
* `locked` item can be user moved/resized just not pushed by other nodes (broke in 1.1.1)
* had incorrectly assume locked = noMove + noSize (user driven) but it's for layout only, so now you have complete choice.
adumesny added a commit to adumesny/gridstack.js that referenced this issue May 29, 2021
* fix gridstack#1767
* `locked` item can be user moved/resized just not pushed by other nodes (broke in 1.1.1)
* had incorrectly assume locked = noMove + noSize (user driven) but it's for layout only, so now you have complete choice.
@adumesny
Copy link
Member

adumesny commented May 29, 2021

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
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants