From 90327001a2476c23fec041f824f8c91c008b1a5d Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Sun, 23 Mar 2025 20:13:14 -0700 Subject: [PATCH] revert this change lock change SHA-1: 5321400b73f23b746581bb0b5e57f89fcfefa684 * Locked not working as expected * fix #2981 --- demo/web2.html | 2 +- doc/CHANGES.md | 4 ++++ src/gridstack.ts | 8 +++----- src/types.ts | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/demo/web2.html b/demo/web2.html index 0f420d3d1..4c7e36e03 100644 --- a/demo/web2.html +++ b/demo/web2.html @@ -63,7 +63,7 @@

Advanced Demo

let children = [ {x: 0, y: 0, w: 4, h: 2, content: '1'}, - {x: 4, y: 0, w: 4, h: 4, locked: true, content: 'I can\'t be moved or dragged, nor pushed by others!
'}, + {x: 4, y: 0, w: 4, h: 4, locked: true, content: 'locked: can\'t be pushed by others, only user!
'}, {x: 8, y: 0, w: 2, h: 2, minW: 2, noResize: true, content: '

Drag me!

...but don\'t resize me!'}, {x: 10, y: 0, w: 2, h: 2, content: '4'}, {x: 0, y: 2, w: 2, h: 2, content: '5'}, diff --git a/doc/CHANGES.md b/doc/CHANGES.md index 811d3d58f..00952538d 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -6,6 +6,7 @@ Change log **Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)* - [11.5.0-dev (TBD)](#1150-dev-tbd) +- [11.5.1 (2025-03-23)](#1151-2025-03-23) - [11.5.0 (2025-03-16)](#1150-2025-03-16) - [11.4.0 (2025-02-27)](#1140-2025-02-27) - [11.3.0 (2025-01-26)](#1130-2025-01-26) @@ -125,6 +126,9 @@ Change log ## 11.5.0-dev (TBD) * feat: [#2854](https://github.com/gridstack/gridstack.js/pull/2854) Removed dynamic stylesheet and migrated to CSS vars. Thank you [lmartorella](https://github.com/lmartorella) +## 11.5.1 (2025-03-23) +* revert: [#2981](https://github.com/gridstack/gridstack.js/issues/2981) Locked was incorrectly changed. fixed doc instead + ## 11.5.0 (2025-03-16) * feat: [#2975](https://github.com/gridstack/gridstack.js/pull/2975) `prepareDragDrop(el, force)` option to force re-creation of the drag&drop event binding * feat: [#2989](https://github.com/gridstack/gridstack.js/pull/2989) new `updateOptions(o: GridStackOptions)` to update PARTIAL list of options after grid as been created diff --git a/src/gridstack.ts b/src/gridstack.ts index bfff7753d..cd34dc817 100644 --- a/src/gridstack.ts +++ b/src/gridstack.ts @@ -2366,16 +2366,14 @@ export class GridStack { const noResize = node.noResize || this.opts.disableResize; // check for disabled grid first - const disable = node.locked || this.opts.staticGrid || (noMove && noResize); + const disable = this.opts.staticGrid || (noMove && noResize); if (force || disable) { if (node._initDD) { this._removeDD(el); // nukes everything instead of just disable, will add some styles back next delete node._initDD; } - if (disable) { - el.classList.add('ui-draggable-disabled', 'ui-resizable-disabled'); // add styles one might depend on #1435 - return this; - } + if (disable) el.classList.add('ui-draggable-disabled', 'ui-resizable-disabled'); // add styles one might depend on #1435 + if (!force) return this; } if (!node._initDD) { diff --git a/src/types.ts b/src/types.ts index 5c18b83e3..795ccec75 100644 --- a/src/types.ts +++ b/src/types.ts @@ -333,7 +333,7 @@ export interface GridStackWidget extends GridStackPosition { 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) */ + /** prevents being pushed by other widgets or api (default?: undefined = un-constrained), which is different from `noMove` (user action only) */ locked?: boolean; /** value for `gs-id` stored on the widget (default?: undefined) */ id?: string;