diff --git a/demo/two.html b/demo/two.html
index 123252bcf..335fa3c79 100644
--- a/demo/two.html
+++ b/demo/two.html
@@ -75,7 +75,7 @@
Two grids demo
// sidebar content (just 2, rest is other behavior) to create when we get dropped, instead of inserting the clone version
let sidebarContent = [
- {content: 'dropped'},
+ {content: 'dropped', id: 'dup_id'}, // test to make sure unique ids are created when dropped mutliple times...
{content: 'max=3', w:2, h:1, maxW: 3},
];
diff --git a/doc/CHANGES.md b/doc/CHANGES.md
index dde957813..ea4f93a6e 100644
--- a/doc/CHANGES.md
+++ b/doc/CHANGES.md
@@ -5,6 +5,7 @@ Change log
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
+- [11.0.1 (2024-10-21)](#1101-2024-10-21)
- [11.0.0 (2024-10-20)](#1100-2024-10-20)
- [10.3.1 (2024-07-21)](#1031-2024-07-21)
- [10.3.0 (2024-06-26)](#1030-2024-06-26)
@@ -114,6 +115,10 @@ Change log
+## 11.0.1 (2024-10-21)
+* fix: [#2834](https://github.com/gridstack/gridstack.js/pull/2834) v11 angular missing package.json
+* fix: [#2835](https://github.com/gridstack/gridstack.js/bug/2835) make sure we have unique USER id
+
## 11.0.0 (2024-10-20)
* feat: [#2826](https://github.com/gridstack/gridstack.js/pull/2826) Lazy loading of widget content until visible (`GridStackOptions.lazyLoad` and `GridStackWidget.lazyLoad`)
* feat: [#2818](https://github.com/gridstack/gridstack.js/pull/2818) support for Angular Component hosting true sub-grids (that size according to parent) without requring them to be only child of grid-item-content.
diff --git a/src/gridstack-engine.ts b/src/gridstack-engine.ts
index 952ed2bd5..f12918c52 100644
--- a/src/gridstack-engine.ts
+++ b/src/gridstack-engine.ts
@@ -352,6 +352,15 @@ export class GridStackEngine {
public prepareNode(node: GridStackNode, resizing?: boolean): GridStackNode {
node._id = node._id ?? GridStackEngine._idSeq++;
+ // make sure USER supplied id are unique in our list, else assign a new one as it will create issues during load/update/etc...
+ const id = node.id;
+ if (id) {
+ let count = 1; // append nice _n rather than some random number
+ while (this.nodes.find(n => n.id === node.id && n !== node)) {
+ node.id = id + '_' + (count++);
+ }
+ }
+
// if we're missing position, have the grid position us automatically (before we set them to 0,0)
if (node.x === undefined || node.y === undefined || node.x === null || node.y === null) {
node.autoPosition = true;