Skip to content

Commit 70ec0e2

Browse files
committed
Update useObserveHeights.ts
1 parent 345a930 commit 70ec0e2

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎packages/main/src/internal/useObserveHeights.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,13 @@ export const useObserveHeights = (
4444
}
4545

4646
if (scrollDown && e.target.scrollTop >= headerContentHeight && !headerCollapsed) {
47-
// Collapsing a section too short to keep the top spacer would shrink the container, clamp scrollTop to 0 and re-expand in a loop.
48-
if (suppressScrollCollapse) {
47+
// Skip the collapse only when it can't be sustained: the section is flagged too short to keep the top spacer
48+
// and the scroll range left after collapse would clamp back toward the top and re-expand in a loop.
49+
const reExpandThreshold = topHeaderHeight + Math.max(0, headerContentHeight - topHeaderHeight);
50+
if (
51+
suppressScrollCollapse &&
52+
e.target.scrollHeight - e.target.clientHeight - headerContentHeight <= reExpandThreshold
53+
) {
4954
return;
5055
}
5156
setIsIntersecting(false);

0 commit comments

Comments
 (0)