Profile: Fix scrolling to Shared Media (#2507)

This commit is contained in:
Alexander Zinchuk 2023-02-08 00:47:34 +01:00
parent cb881a1809
commit dcee60e77e
2 changed files with 3 additions and 8 deletions

View File

@ -201,7 +201,7 @@ const Profile: FC<OwnProps & StateProps> = ({
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);

View File

@ -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<HTMLDivElement>('.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]) => {