@@ -66,11 +66,9 @@ export const useObserveHeights = (
6666
6767 // top header
6868 useEffect ( ( ) => {
69- const headerContentResizeObserver = new ResizeObserver ( ( [ header ] ) => {
70- // Firefox implements `borderBoxSize` as a single content rect, rather than an array
71- const borderBoxSize = Array . isArray ( header . borderBoxSize ) ? header . borderBoxSize [ 0 ] : header . borderBoxSize ;
72- // Safari doesn't implement `borderBoxSize`
73- setTopHeaderHeight ( borderBoxSize ?. blockSize ?? header . target . getBoundingClientRect ( ) . height ) ;
69+ const headerContentResizeObserver = new ResizeObserver ( ( [ entry ] ) => {
70+ const { blockSize } = entry . borderBoxSize [ 0 ] ;
71+ setTopHeaderHeight ( blockSize ) ;
7472 } ) ;
7573 if ( topHeaderRef ?. current ) {
7674 headerContentResizeObserver . observe ( topHeaderRef . current ) ;
@@ -82,14 +80,10 @@ export const useObserveHeights = (
8280
8381 // header content
8482 useEffect ( ( ) => {
85- const headerContentResizeObserver = new ResizeObserver ( ( [ headerContent ] ) => {
86- if ( isIntersecting ) {
87- // Firefox implements `borderBoxSize` as a single content rect, rather than an array
88- const borderBoxSize = Array . isArray ( headerContent . borderBoxSize )
89- ? headerContent . borderBoxSize [ 0 ]
90- : headerContent . borderBoxSize ;
91- // Safari doesn't implement `borderBoxSize`
92- setHeaderContentHeight ( borderBoxSize ?. blockSize ?? headerContent . target . getBoundingClientRect ( ) . height ) ;
83+ const headerContentResizeObserver = new ResizeObserver ( ( [ entry ] ) => {
84+ if ( isIntersecting || fixedHeader ) {
85+ const { blockSize } = entry . borderBoxSize [ 0 ] ;
86+ setHeaderContentHeight ( blockSize ) ;
9387 }
9488 } ) ;
9589
@@ -99,7 +93,7 @@ export const useObserveHeights = (
9993 return ( ) => {
10094 headerContentResizeObserver . disconnect ( ) ;
10195 } ;
102- } , [ isIntersecting ] ) ;
96+ } , [ isIntersecting , fixedHeader ] ) ;
10397 const totalHeaderHeight = noHeader ? 0 : topHeaderHeight + headerContentHeight ;
10498
10599 return { topHeaderHeight, headerContentHeight, totalHeaderHeight, headerCollapsed } ;
0 commit comments