Profile: Fix scrolling to Shared Media (#2507)
This commit is contained in:
parent
cb881a1809
commit
dcee60e77e
@ -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);
|
||||
|
||||
|
||||
@ -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]) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user