@@ -347,4 +347,111 @@ describe('overlayRenderContainer', () => {
347347 expect ( referenceContainer . element . getBoundingClientRect ) . toHaveBeenCalledTimes ( 2 ) ;
348348 expect ( parentContainer . getBoundingClientRect ) . toHaveBeenCalledTimes ( 2 ) ;
349349 } ) ;
350+
351+ test ( 'updateAllPositions forces position recalculation for visible panels' , async ( ) => {
352+ const cut = new OverlayRenderContainer (
353+ parentContainer ,
354+ fromPartial < DockviewComponent > ( { } )
355+ ) ;
356+
357+ const panelContentEl1 = document . createElement ( 'div' ) ;
358+ const panelContentEl2 = document . createElement ( 'div' ) ;
359+
360+ const onDidVisibilityChange1 = new Emitter < any > ( ) ;
361+ const onDidDimensionsChange1 = new Emitter < any > ( ) ;
362+ const onDidLocationChange1 = new Emitter < any > ( ) ;
363+
364+ const onDidVisibilityChange2 = new Emitter < any > ( ) ;
365+ const onDidDimensionsChange2 = new Emitter < any > ( ) ;
366+ const onDidLocationChange2 = new Emitter < any > ( ) ;
367+
368+ const panel1 = fromPartial < IDockviewPanel > ( {
369+ api : {
370+ id : 'panel1' ,
371+ onDidVisibilityChange : onDidVisibilityChange1 . event ,
372+ onDidDimensionsChange : onDidDimensionsChange1 . event ,
373+ onDidLocationChange : onDidLocationChange1 . event ,
374+ isVisible : true ,
375+ location : { type : 'grid' } ,
376+ } ,
377+ view : {
378+ content : {
379+ element : panelContentEl1 ,
380+ } ,
381+ } ,
382+ group : {
383+ api : {
384+ location : { type : 'grid' } ,
385+ } ,
386+ } ,
387+ } ) ;
388+
389+ const panel2 = fromPartial < IDockviewPanel > ( {
390+ api : {
391+ id : 'panel2' ,
392+ onDidVisibilityChange : onDidVisibilityChange2 . event ,
393+ onDidDimensionsChange : onDidDimensionsChange2 . event ,
394+ onDidLocationChange : onDidLocationChange2 . event ,
395+ isVisible : false , // This panel is not visible
396+ location : { type : 'grid' } ,
397+ } ,
398+ view : {
399+ content : {
400+ element : panelContentEl2 ,
401+ } ,
402+ } ,
403+ group : {
404+ api : {
405+ location : { type : 'grid' } ,
406+ } ,
407+ } ,
408+ } ) ;
409+
410+ // Mock getBoundingClientRect for consistent testing
411+ jest . spyOn ( referenceContainer . element , 'getBoundingClientRect' )
412+ . mockReturnValue (
413+ fromPartial < DOMRect > ( {
414+ left : 100 ,
415+ top : 200 ,
416+ width : 150 ,
417+ height : 250 ,
418+ } )
419+ ) ;
420+
421+ jest . spyOn ( parentContainer , 'getBoundingClientRect' ) . mockReturnValue (
422+ fromPartial < DOMRect > ( {
423+ left : 50 ,
424+ top : 100 ,
425+ width : 200 ,
426+ height : 300 ,
427+ } )
428+ ) ;
429+
430+ // Attach both panels
431+ const container1 = cut . attach ( { panel : panel1 , referenceContainer } ) ;
432+ const container2 = cut . attach ( { panel : panel2 , referenceContainer } ) ;
433+
434+ await exhaustMicrotaskQueue ( ) ;
435+ await exhaustAnimationFrame ( ) ;
436+
437+ // Clear previous calls to getBoundingClientRect
438+ jest . clearAllMocks ( ) ;
439+
440+ // Call updateAllPositions
441+ cut . updateAllPositions ( ) ;
442+
443+ // Should trigger resize for visible panels only
444+ await exhaustAnimationFrame ( ) ;
445+
446+ // Verify that positioning was updated for visible panel
447+ expect ( container1 . style . left ) . toBe ( '50px' ) ;
448+ expect ( container1 . style . top ) . toBe ( '100px' ) ;
449+ expect ( container1 . style . width ) . toBe ( '150px' ) ;
450+ expect ( container1 . style . height ) . toBe ( '250px' ) ;
451+
452+ // Verify getBoundingClientRect was called for visible panel only
453+ // updateAllPositions should call the resize function which triggers getBoundingClientRect
454+ expect ( referenceContainer . element . getBoundingClientRect ) . toHaveBeenCalled ( ) ;
455+ expect ( parentContainer . getBoundingClientRect ) . toHaveBeenCalled ( ) ;
456+ } ) ;
350457} ) ;
0 commit comments