@@ -82,6 +82,38 @@ describe('GridStack Vue wrapper', () => {
8282 expect ( document . querySelector ( '[data-testid="portal"]' ) ?. textContent ) . toBe ( 'hello' )
8383 } )
8484
85+ it ( 'renders a drag-in widget that has a component but no id (#2976)' , async ( ) => {
86+ const T = defineComponent ( {
87+ props : { label : { type : String , default : '' } } ,
88+ setup ( props ) {
89+ return ( ) => h ( 'span' , { 'data-testid' : 'portal' } , props . label )
90+ } ,
91+ } )
92+
93+ const Root = defineComponent ( {
94+ setup ( ) {
95+ const options = {
96+ column : 12 , cellHeight : 50 , margin : 0 ,
97+ children : [ ] ,
98+ }
99+ return ( ) =>
100+ h ( GridStack , { options, components : { T } } )
101+ } ,
102+ } )
103+
104+ ; ( { app, container } = mountApp ( Root ) )
105+ await flush ( )
106+
107+ const gridEl = container . querySelector ( '.grid-stack' ) as GridHTMLElement
108+ const grid = gridEl . gridstack !
109+
110+ // drag-in nodes don't have ids, only the spec they carry.
111+ grid . addWidget ( { x : 0 , y : 0 , w : 2 , h : 2 , component : 'T' , props : { label : 'hello' } } )
112+ await flush ( )
113+
114+ expect ( document . querySelector ( '[data-testid="portal"]' ) ?. textContent ) . toBe ( 'hello' )
115+ } )
116+
85117 it ( 'save() merges useWidgetSerializer into widget props' , async ( ) => {
86118 const Num = defineComponent ( {
87119 props : { start : { type : Number , default : 0 } } ,
0 commit comments