From dcee60e77e4a459f70bfc309a811230154021fa8 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Wed, 8 Feb 2023 00:47:34 +0100 Subject: [PATCH] Profile: Fix scrolling to Shared Media (#2507) --- src/components/right/Profile.tsx | 2 +- src/components/right/hooks/useProfileState.ts | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/components/right/Profile.tsx b/src/components/right/Profile.tsx index c86fb4014..7ae002a5a 100644 --- a/src/components/right/Profile.tsx +++ b/src/components/right/Profile.tsx @@ -201,7 +201,7 @@ const Profile: FC = ({ const isFirstTab = resultType === 'members' || (!hasMembersTab && resultType === 'media'); const activeKey = tabs.findIndex(({ type }) => type === resultType); - const { handleScroll } = useProfileState(containerRef, tabType, profileState, onProfileStateChange, isFirstTab); + const { handleScroll } = useProfileState(containerRef, resultType, profileState, onProfileStateChange); const { applyTransitionFix, releaseTransitionFix } = useTransitionFixes(containerRef); diff --git a/src/components/right/hooks/useProfileState.ts b/src/components/right/hooks/useProfileState.ts index 7b6f17476..ab4914bee 100644 --- a/src/components/right/hooks/useProfileState.ts +++ b/src/components/right/hooks/useProfileState.ts @@ -18,14 +18,9 @@ export default function useProfileState( tabType: string, profileState: ProfileState, onProfileStateChange: (state: ProfileState) => void, - isFirstTab?: boolean, ) { // Scroll to tabs if needed - useEffectWithPrevDeps(([prevTabType, prevIsFirstTab]) => { - if (isFirstTab === prevIsFirstTab) { - return; - } - + useEffectWithPrevDeps(([prevTabType]) => { if (prevTabType && prevTabType !== tabType) { const container = containerRef.current!; const tabsEl = container.querySelector('.TabList')!; @@ -38,7 +33,7 @@ export default function useProfileState( }, PROGRAMMATIC_SCROLL_TIMEOUT_MS); } } - }, [tabType, isFirstTab, onProfileStateChange, containerRef]); + }, [tabType, onProfileStateChange, containerRef]); // Scroll to top useEffectWithPrevDeps(([prevProfileState]) => {