Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/two.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ <h1>Two grids demo</h1>

// 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},
];

Expand Down
5 changes: 5 additions & 0 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Change log
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**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)
Expand Down Expand Up @@ -114,6 +115,10 @@ Change log

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## 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.
Expand Down
9 changes: 9 additions & 0 deletions src/gridstack-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down