@@ -5,7 +5,6 @@ export function useGridDimensions() {
55 const gridRef = useRef < HTMLDivElement > ( null ) ;
66 const [ inlineSize , setInlineSize ] = useState ( 1 ) ;
77 const [ blockSize , setBlockSize ] = useState ( 1 ) ;
8- const [ horizontalScrollbarHeight , setHorizontalScrollbarHeight ] = useState ( 0 ) ;
98
109 useLayoutEffect ( ( ) => {
1110 const { ResizeObserver } = window ;
@@ -14,25 +13,18 @@ export function useGridDimensions() {
1413 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1514 if ( ResizeObserver == null ) return ;
1615
17- const { clientWidth, clientHeight, offsetWidth, offsetHeight } = gridRef . current ! ;
18- const { width, height } = gridRef . current ! . getBoundingClientRect ( ) ;
19- const initialHorizontalScrollbarHeight = offsetHeight - clientHeight ;
20- const initialWidth = width - offsetWidth + clientWidth ;
21- const initialHeight = height - initialHorizontalScrollbarHeight ;
16+ const { clientWidth, clientHeight } = gridRef . current ! ;
2217
23- setInlineSize ( initialWidth ) ;
24- setBlockSize ( initialHeight ) ;
25- setHorizontalScrollbarHeight ( initialHorizontalScrollbarHeight ) ;
18+ setInlineSize ( clientWidth ) ;
19+ setBlockSize ( clientHeight ) ;
2620
2721 const resizeObserver = new ResizeObserver ( ( entries ) => {
2822 const size = entries [ 0 ] . contentBoxSize [ 0 ] ;
29- const { clientHeight, offsetHeight } = gridRef . current ! ;
3023
3124 // we use flushSync here to avoid flashing scrollbars
3225 flushSync ( ( ) => {
3326 setInlineSize ( size . inlineSize ) ;
3427 setBlockSize ( size . blockSize ) ;
35- setHorizontalScrollbarHeight ( offsetHeight - clientHeight ) ;
3628 } ) ;
3729 } ) ;
3830 resizeObserver . observe ( gridRef . current ! ) ;
@@ -42,5 +34,5 @@ export function useGridDimensions() {
4234 } ;
4335 } , [ ] ) ;
4436
45- return [ gridRef , inlineSize , blockSize , horizontalScrollbarHeight ] as const ;
37+ return [ gridRef , inlineSize , blockSize ] as const ;
4638}
0 commit comments