Skip to content

Locked not working as expected #2981

Description

@E4RIJMP

Hi, i don't know if it's an issue with the documentation or the implementation. But the documentation reads:

/** prevent direct resizing by the user (default?: undefined = un-constrained) */
noResize?: boolean;
/** prevents direct moving by the user (default?: undefined = un-constrained) */
noMove?: boolean;
/** same as noMove+noResize but also prevents being pushed by other widgets or api (default?: undefined = un-constrained) */
locked?: boolean;

So for locked I would assume that it does the same as noResize and noMove:

same as noMove+noResize but also ...

But if I create an item where locked is true, it can still be moved and resized via mouse. This is not the case if I create an item where noResize is true and noMove is true.

Steps to reproduce

  • Create an item where locked is true
  • Create an item noResize is true and noMove is true
  • Try to move either via mouse

https://jsfiddle.net/7uognfyp/

Expected behavior

Neither item can be resized or moved.

Activity

  1. adumesny commented on Mar 4, 2025

    @adumesny
    Member

    yeah, this is broken https://gridstackjs.com/demo/web2.html while demo 2 here works as expected

  2. added a commit that references this issue on Mar 16, 2025
    5321400
  3. adumesny commented on Mar 16, 2025

    @adumesny
    Member

    fixed in next release

  4. DBolderman commented on Mar 18, 2025

    @DBolderman

    This fix breaks functionality how we use this based on how it is mentioned in the documentation (https://github.com/gridstack/gridstack.js/tree/master/doc):

    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.

    With this option we keep all present widgets on their place while moving or resizing one widget. When upgrading to version 11.5.0 all widgets are now completely locked. Adding properties noMove=false and noResize=false does not work to create the functionality as stated in the documentation.

  5. adumesny commented on Mar 18, 2025

    @adumesny
    Member

    @DBolderman you are absolutely correct, I keep forgeting what locked means (I don't use it) as different from the other 2 flags... and jumped to a 'fix' in a rush late at night. will revert and publish a patch. thanks for catching that....

  6. E4RIJMP commented on Mar 18, 2025

    @E4RIJMP
    Author

    Then this documentation for locked should be changed accordingly:
    same as noMove+noResize but also prevents being pushed by other widgets or api (default?: undefined = un-constrained)

    https://github.com/gridstack/gridstack.js/blob/a10cba698efb2903532d6028c88047e7b7278cf8/src/types.ts#L336C2-L336C127

  7. added a commit that references this issue on Mar 24, 2025
    9032700
  8. adumesny commented on Mar 24, 2025

    @adumesny
    Member

    fixed in just released v11.5.1 (and doc updated)

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions