Skip to content

Commit 59956ec

Browse files
committed
demo: nested drop
more for #2590
1 parent b632373 commit 59956ec

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

demo/nested.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ <h1>Nested grids demo</h1>
5959
minRow: 2, // don't collapse when empty
6060
acceptWidgets: true,
6161
id: 'main',
62+
subGridOpts: subOptions, // all sub grids will default to those
6263
children: [
6364
{x:0, y:0, content: 'regular item'},
64-
{x:1, y:0, w:4, h:4, sizeToContent: true, subGridOpts: {children: sub1, id:'sub1_grid', class: 'sub1', ...subOptions}},
65-
{x:5, y:0, w:3, h:4, subGridOpts: {children: sub2, id:'sub2_grid', class: 'sub2', ...subOptions}},
65+
{x:1, y:0, w:4, h:4, sizeToContent: true, subGridOpts: {children: sub1, id:'sub1_grid', class: 'sub1'}},
66+
{x:5, y:0, w:3, h:4, subGridOpts: {children: sub2, id:'sub2_grid', class: 'sub2'}},
6667
]
6768
};
6869

@@ -108,12 +109,11 @@ <h1>Nested grids demo</h1>
108109
// if we don't have a prevNode that means it came from toolbar, which today is the only nested case (else check for some node.el.getAttribute or some custom field...)
109110
if (prevNode) return;
110111

111-
// clear the content and make it a subgrid
112+
// clear the content then make it a subgrid
112113
n.el.querySelector('.grid-stack-item-content').innerHTML = '';
113-
114-
// let nodeToAdd = { subGridOpts: {children: [{content: 'nest 1'}, {content: 'nest 2'}], ...subOptions }} TODO that is correct info ?
115-
let nodeToAdd = { ...subOptions, subGridOpts: subOptions, children: [{content: 'nest 1'}, {content: 'nest 2'}]}
114+
let nodeToAdd = { children: [{content: 'nest 1'}, {content: 'nest 2'}]};
116115
let subgrid = n.grid.makeSubGrid(n.el, nodeToAdd, undefined, false);
116+
117117
// add a listener to the subgrid to allow widgets to be added into this newly created nested widget
118118
subgrid.on('dropped', droppedHandler);
119119
}

doc/CHANGES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ Change log
111111
* feat: [#2574](https://github.com/gridstack/gridstack.js/pull/2574) Allow cell height in cm and mm units
112112
* fix: [#2577](https://github.com/gridstack/gridstack.js/issues/2577) ui-resizable-s/-n style fix
113113
* fix: [#2576](https://github.com/gridstack/gridstack.js/issues/2576) column('none') now ignores layouts
114-
* fix: [#2560](https://github.com/gridstack/gridstack.js/issues/2560) nested grid fix (enter can call leave which can call enter again).
114+
* fix: [#2560](https://github.com/gridstack/gridstack.js/issues/2560) nested grid fix (enter can call leave which can call enter again) - Thank you [v1talii-dev](https://github.com/v1talii-dev)
115+
* doc: nested.htm now has nested create and drag&drop example - Thank you [fredericrous](https://github.com/fredericrous)
115116

116117
## 10.0.1 (2023-12-10)
117118
* fix: [#2552](https://github.com/gridstack/gridstack.js/issues/2552) DOM init doesn't sizeToContent

src/gridstack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ export class GridStack {
530530
grid = grid.parentGridItem?.grid;
531531
}
532532
//... and set the create options
533-
ops = Utils.cloneDeep({...(subGridTemplate || {}), children: undefined, ...(ops || node.subGridOpts)});
533+
ops = Utils.cloneDeep({...(subGridTemplate || {}), children: undefined, ...(ops || node.subGridOpts || {})});
534534
node.subGridOpts = ops;
535535

536536
// if column special case it set, remember that flag and set default

0 commit comments

Comments
 (0)