Skip to content

Locked widgets cannot be moved by the user #1767

Closed

Description

@ztessema

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.

Activity

  1. adumesny commented on May 27, 2021

    @adumesny
    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.

  2. ztessema commented on May 27, 2021

    @ztessema
    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?

  3. ztessema commented on May 27, 2021

    @ztessema
    Author

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

  4. adumesny commented on May 27, 2021

    @adumesny
    Member

    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.

  5. added 2 commits that reference this issue on May 29, 2021
    9734eff
    fdbce47
  6. 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