Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1a6fd4b

Browse files
committed
tweak to gsCreateNgComponents deserialize
1 parent e1bfb42 commit 1a6fd4b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

angular/projects/lib/src/lib/gridstack.component.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,16 @@ export function gsCreateNgComponents(host: GridCompHTMLElement | HTMLElement, w:
232232
gridItem.ref = gridItemRef
233233

234234
// IFF we're not a subGrid, define what type of component to create as child, OR you can do it GridstackItemComponent template, but this is more generic
235-
const selector = (w as NgGridStackWidget).selector;
236-
const type = selector ? GridstackComponent.selectorToType[selector] : undefined;
237-
if (!w.subGridOpts && type) {
238-
const childWidget = gridItem.container?.createComponent(type)?.instance as BaseWidget;
239-
if (typeof childWidget?.serialize === 'function' && typeof childWidget?.deserialize === 'function') {
240-
// proper BaseWidget subclass, save it and load additional data
241-
gridItem.childWidget = childWidget;
242-
childWidget.deserialize(w);
235+
if (!w.subGridOpts) {
236+
const selector = (w as NgGridStackWidget).selector;
237+
const type = selector ? GridstackComponent.selectorToType[selector] : undefined;
238+
if (type) {
239+
const childWidget = gridItem.container?.createComponent(type)?.instance as BaseWidget;
240+
// if proper BaseWidget subclass, save it and load additional data
241+
if (childWidget && typeof childWidget.serialize === 'function' && typeof childWidget.deserialize === 'function') {
242+
gridItem.childWidget = childWidget;
243+
childWidget.deserialize(w);
244+
}
243245
}
244246
}
245247

0 commit comments

Comments
 (0)