@@ -1341,6 +1341,60 @@ describe('Devtools', () => {
13411341 )
13421342 } )
13431343
1344+ it ( 'should restore "width" to the rendered minimum when the panel is dragged below its content width' , ( ) => {
1345+ const initialWidth = 400
1346+ // The panel uses `min-width: min-content`, so the rendered width may
1347+ // exceed the 192px `minWidth` constant when its children are wider; any
1348+ // value > 192 here triggers the `localStore.width < newWidth` restore
1349+ // branch.
1350+ const renderedMinWidth = 250
1351+ const rendered = renderDevtools (
1352+ { position : 'left' , initialIsOpen : true } ,
1353+ { 'TanstackQueryDevtools.width' : String ( initialWidth ) } ,
1354+ )
1355+
1356+ const handle = rendered . getByLabelText ( 'Resize devtools panel' )
1357+ const panel = handle . parentElement
1358+ expect ( panel ) . toBeInstanceOf ( HTMLElement )
1359+ const getBoundingClientRect = vi
1360+ . spyOn ( panel ! , 'getBoundingClientRect' )
1361+ . mockReturnValueOnce ( {
1362+ height : 0 ,
1363+ width : initialWidth ,
1364+ x : 0 ,
1365+ y : 0 ,
1366+ top : 0 ,
1367+ right : 0 ,
1368+ bottom : 0 ,
1369+ left : 0 ,
1370+ toJSON : ( ) => ( { } ) ,
1371+ } )
1372+ getBoundingClientRect . mockReturnValue ( {
1373+ height : 0 ,
1374+ width : renderedMinWidth ,
1375+ x : 0 ,
1376+ y : 0 ,
1377+ top : 0 ,
1378+ right : 0 ,
1379+ bottom : 0 ,
1380+ left : 0 ,
1381+ toJSON : ( ) => ( { } ) ,
1382+ } )
1383+
1384+ // Drag 300px left shrinks the panel to 100 — below `minWidth`, so the
1385+ // clamp + restore branches both fire.
1386+ fireEvent . mouseDown ( handle , { clientX : 300 , clientY : 0 } )
1387+ fireEvent (
1388+ document ,
1389+ new MouseEvent ( 'mousemove' , { clientX : 0 , clientY : 0 } ) ,
1390+ )
1391+ fireEvent ( document , new MouseEvent ( 'mouseup' ) )
1392+
1393+ expect ( Number ( localStorage . getItem ( 'TanstackQueryDevtools.width' ) ) ) . toBe (
1394+ renderedMinWidth ,
1395+ )
1396+ } )
1397+
13441398 it ( 'should close the query details panel when dragging shrinks the panel below the minimum height' , ( ) => {
13451399 queryClient . setQueryData ( [ 'shrink-below-min-height' ] , [ { id : 1 } ] )
13461400 const rendered = renderDevtools ( {
0 commit comments