@@ -155,14 +155,17 @@ const ObjectPage: FC<ObjectPagePropTypes> = forwardRef((props: ObjectPagePropTyp
155
155
const lastSectionDomRef = sections [ sections . length - 1 ] ;
156
156
const subSections = lastSectionDomRef . querySelectorAll ( '[id^="ObjectPageSubSection"]' ) ;
157
157
158
- let domRef = null ;
158
+ let lastSubSectionHeight = null ;
159
159
if ( subSections . length > 0 ) {
160
- domRef = subSections [ subSections . length - 1 ] ;
160
+ lastSubSectionHeight = ( subSections [ subSections . length - 1 ] as HTMLElement ) . offsetHeight ;
161
161
} else {
162
- domRef = lastSectionDomRef ;
162
+ lastSubSectionHeight =
163
+ ( lastSectionDomRef as HTMLElement ) . offsetHeight -
164
+ ( lastSectionDomRef . querySelector ( "[role='heading']" ) as HTMLElement ) . offsetHeight ;
163
165
}
164
166
165
- let heightDiff = contentContainer . current . offsetHeight - domRef . offsetHeight ;
167
+ let heightDiff = contentContainer . current . offsetHeight - lastSubSectionHeight ;
168
+
166
169
heightDiff = heightDiff > 0 ? heightDiff : 0 ;
167
170
fillerDivDomRef . current . style . height = `${ heightDiff } px` ;
168
171
setScrollbarHeight ( ) ;
@@ -442,15 +445,17 @@ const ObjectPage: FC<ObjectPagePropTypes> = forwardRef((props: ObjectPagePropTyp
442
445
if ( expandHeaderActive ) {
443
446
setExpandHeaderActive ( false ) ;
444
447
}
445
-
446
- const threshold = 64 ;
448
+ const thresholdCollapse = 64 ;
449
+ const thresholdExpand = 52 ;
447
450
const baseScrollValue =
448
451
activeContainer . current === contentContainer . current
449
452
? e . target . scrollTop
450
453
: getProportionateScrollTop ( activeInnerContainer , passiveInnerContainer , e . target . scrollTop ) ;
451
454
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 ) {
454
459
lastScrolledContainer . current = activeContainer . current ;
455
460
if ( shouldBeCollapsed ) {
456
461
collapsedHeaderFiller . current . style . height = `${ 64 } px` ;
@@ -463,7 +468,7 @@ const ObjectPage: FC<ObjectPagePropTypes> = forwardRef((props: ObjectPagePropTyp
463
468
setCollapsedHeader ( shouldBeCollapsed ) ;
464
469
} else {
465
470
const newScrollValue =
466
- collapsedHeader && e . target . scrollTop > threshold + 50
471
+ collapsedHeader && e . target . scrollTop > thresholdCollapse + 50
467
472
? e . target . scrollTop
468
473
: getProportionateScrollTop ( activeInnerContainer , passiveInnerContainer , e . target . scrollTop ) ;
469
474
0 commit comments