You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two module have a cyclic relationship: class Utils and class GridStack. That should be the key clue.
My guess is that there may have been a change in nextjs15's packaging strategy that caused the handling of circular dependencies to behave differently than before. I'll explore nextjs15's changes in this regard.
Maybe also improve the gridstack cyclic dependency code?
/** create the default grid item divs, and content possibly lazy loaded calling GridStack.renderCB */staticcreateWidgetDivs(itemClass: string,n: GridStackNode,cb: (cont: HTMLElement,n: GridStackNode)=>void): HTMLElement{
const el=Utils.createDiv(['grid-stack-item',itemClass]);constcont=Utils.createDiv(['grid-stack-item-content'],el);if(Utils.lazyLoad(n)){if(!n.visibleObservable){n.visibleObservable=newIntersectionObserver(([entry])=>{if(entry.isIntersecting){n.visibleObservable?.disconnect();deleten.visibleObservable;cb(cont,n);n.grid?.prepareDragDrop(n.el);}});window.setTimeout(()=>n.visibleObservable?.observe(el));// wait until callee sets position attributes}}elsecb(cont,n);returnel;}
publicaddWidget(w: GridStackWidget): GridItemHTMLElement{if(typeofw==='string'){console.error('V11: GridStack.addWidget() does not support string anymore. see #2736');return;}if((wasHTMLElement).ELEMENT_NODE){console.error('V11: GridStack.addWidget() does not support HTMLElement anymore. use makeWidget()');returnthis.makeWidget(wasHTMLElement);}letel: GridItemHTMLElement;letnode: GridStackNode=w;node.grid=this;if(node?.el){el=node.el;// re-use element stored in the node}elseif(GridStack.addRemoveCB){el=GridStack.addRemoveCB(this.el,w,true,false);}else{el=Utils.createWidgetDivs(this.opts.itemClass,node,(cont,n)=>{GridStack.renderCB(cont,n);});}if(!el)return;// if the caller ended up initializing the widget in addRemoveCB, or we stared with one already, skip the restnode=el.gridstackNode;if(node&&el.parentElement===this.el&&this.engine.nodes.find(n=>n._id===node._id))returnel;// Tempting to initialize the passed in opt with default and valid values, but this break knockout demos// as the actual value are filled in when _prepareElement() calls el.getAttribute('gs-xyz') before adding the node.// So make sure we load any DOM attributes that are not specified in passed in options (which override)constdomAttr=this._readAttr(el);Utils.defaults(w,domAttr);this.engine.prepareNode(w);// this._writeAttr(el, w); why write possibly incorrect values back when makeWidget() will ?this.el.appendChild(el);this.makeWidget(el,w);returnel;}
yeah, I just moved it over. I don't think many people use that newer Util code as that was added recently for delay loading, and lib does it automatically, and wrapper like Angular have their own delayLoading code anyway...
should be fixed in next release. either way CB would have been breaking too..
Activity
adumesny commentedon Feb 24, 2025
@Aysnine ^^^
Aysnine commentedon Feb 27, 2025
This is a tricky one, and let's start with the conclusion: gridstack works fine in nextjs 14, but in nextjs 15 it has the problem you describe.
I need to look into this, until then you can try nextjs 14:
npx create-next-app@14Aysnine commentedon Feb 27, 2025
@adumesny
Two module have a cyclic relationship:
class Utilsandclass GridStack. That should be the key clue.My guess is that there may have been a change in nextjs15's packaging strategy that caused the handling of circular dependencies to behave differently than before. I'll explore nextjs15's changes in this regard.
Maybe also improve the gridstack cyclic dependency code?
adumesny commentedon Feb 27, 2025
this would be the place... an API breakage if it were to move
GridStack.renderCBelsewhereor move it out of Util (likely better smaller break)
Aysnine commentedon Feb 27, 2025
@adumesny
add
cbparam?Util to GridStack.createWidgetDivs() move
adumesny commentedon Feb 27, 2025
yeah, I just moved it over. I don't think many people use that newer Util code as that was added recently for delay loading, and lib does it automatically, and wrapper like Angular have their own delayLoading code anyway...
should be fixed in next release. either way CB would have been breaking too..
this.createWidgetDivs() since it needs this.opts.itemClass anyway, in…
Aysnine commentedon Feb 28, 2025
@chungwong @adumesny
Checked. Nextjs15 works fine with gridstack@11.4.0