@@ -155,14 +155,17 @@ const ObjectPage: FC<ObjectPagePropTypes> = forwardRef((props: ObjectPagePropTyp
155155 const lastSectionDomRef = sections [ sections . length - 1 ] ;
156156 const subSections = lastSectionDomRef . querySelectorAll ( '[id^="ObjectPageSubSection"]' ) ;
157157
158- let domRef = null ;
158+ let lastSubSectionHeight = null ;
159159 if ( subSections . length > 0 ) {
160- domRef = subSections [ subSections . length - 1 ] ;
160+ lastSubSectionHeight = ( subSections [ subSections . length - 1 ] as HTMLElement ) . offsetHeight ;
161161 } else {
162- domRef = lastSectionDomRef ;
162+ lastSubSectionHeight =
163+ ( lastSectionDomRef as HTMLElement ) . offsetHeight -
164+ ( lastSectionDomRef . querySelector ( "[role='heading']" ) as HTMLElement ) . offsetHeight ;
163165 }
164166
165- let heightDiff = contentContainer . current . offsetHeight - domRef . offsetHeight ;
167+ let heightDiff = contentContainer . current . offsetHeight - lastSubSectionHeight ;
168+
166169 heightDiff = heightDiff > 0 ? heightDiff : 0 ;
167170 fillerDivDomRef . current . style . height = `${ heightDiff } px` ;
168171 setScrollbarHeight ( ) ;
@@ -442,15 +445,17 @@ const ObjectPage: FC<ObjectPagePropTypes> = forwardRef((props: ObjectPagePropTyp
442445 if ( expandHeaderActive ) {
443446 setExpandHeaderActive ( false ) ;
444447 }
445-
446- const threshold = 64 ;
448+ const thresholdCollapse = 64 ;
449+ const thresholdExpand = 52 ;
447450 const baseScrollValue =
448451 activeContainer . current === contentContainer . current
449452 ? e . target . scrollTop
450453 : getProportionateScrollTop ( activeInnerContainer , passiveInnerContainer , e . target . scrollTop ) ;
451454
452- const shouldBeCollapsed = baseScrollValue > threshold ;
453- if ( collapsedHeader !== shouldBeCollapsed ) {
455+ let shouldBeCollapsed = ! collapsedHeader && baseScrollValue > thresholdCollapse ;
456+ let shouldBeExpanded = collapsedHeader && baseScrollValue < thresholdExpand ;
457+
458+ if ( shouldBeCollapsed || shouldBeExpanded ) {
454459 lastScrolledContainer . current = activeContainer . current ;
455460 if ( shouldBeCollapsed ) {
456461 collapsedHeaderFiller . current . style . height = `${ 64 } px` ;
@@ -463,7 +468,7 @@ const ObjectPage: FC<ObjectPagePropTypes> = forwardRef((props: ObjectPagePropTyp
463468 setCollapsedHeader ( shouldBeCollapsed ) ;
464469 } else {
465470 const newScrollValue =
466- collapsedHeader && e . target . scrollTop > threshold + 50
471+ collapsedHeader && e . target . scrollTop > thresholdCollapse + 50
467472 ? e . target . scrollTop
468473 : getProportionateScrollTop ( activeInnerContainer , passiveInnerContainer , e . target . scrollTop ) ;
469474
0 commit comments