From 5fb31e160321def0e591a29fbf6f2a8f611d84e7 Mon Sep 17 00:00:00 2001 From: zubiden <19638254+zubiden@users.noreply.github.com> Date: Sat, 1 Mar 2025 17:59:05 +0100 Subject: [PATCH] Profile: Fix header update on scroll (#5627) --- src/components/right/hooks/useProfileState.ts | 2 +- src/components/right/hooks/useTransitionFixes.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/right/hooks/useProfileState.ts b/src/components/right/hooks/useProfileState.ts index 72ae54251..c3f352369 100644 --- a/src/components/right/hooks/useProfileState.ts +++ b/src/components/right/hooks/useProfileState.ts @@ -89,7 +89,7 @@ export default function useProfileState( } let state: ProfileState = ProfileState.Profile; - if (container.scrollTop >= tabListEl.offsetTop) { + if (Math.ceil(container.scrollTop) >= tabListEl.offsetTop) { state = getStateFromTabType(tabType); } diff --git a/src/components/right/hooks/useTransitionFixes.ts b/src/components/right/hooks/useTransitionFixes.ts index 41db55b6c..ec0c343bb 100644 --- a/src/components/right/hooks/useTransitionFixes.ts +++ b/src/components/right/hooks/useTransitionFixes.ts @@ -4,6 +4,9 @@ import { requestMeasure, requestMutation } from '../../../lib/fasterdom/fasterdo import useLastCallback from '../../../hooks/useLastCallback'; +// Sometimes px values are rounded +const ROUNDING_COMPENSATION_PX = 1; + export default function useTransitionFixes( containerRef: { current: HTMLDivElement | null }, transitionElSelector = '.Transition.shared-media-transition', @@ -15,7 +18,7 @@ export default function useTransitionFixes( const transitionEl = container.querySelector(transitionElSelector); const tabsEl = container.querySelector('.TabList'); if (transitionEl && tabsEl) { - const newHeight = container.offsetHeight - tabsEl.offsetHeight; + const newHeight = container.offsetHeight - tabsEl.offsetHeight + ROUNDING_COMPENSATION_PX; requestMutation(() => { transitionEl.style.minHeight = `${newHeight}px`;