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 isFirstTab = resultType === 'members' || (!hasMembersTab && resultType === 'media');
|
||||||
const activeKey = tabs.findIndex(({ type }) => type === resultType);
|
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);
|
const { applyTransitionFix, releaseTransitionFix } = useTransitionFixes(containerRef);
|
||||||
|
|
||||||
|
|||||||
@ -18,14 +18,9 @@ export default function useProfileState(
|
|||||||
tabType: string,
|
tabType: string,
|
||||||
profileState: ProfileState,
|
profileState: ProfileState,
|
||||||
onProfileStateChange: (state: ProfileState) => void,
|
onProfileStateChange: (state: ProfileState) => void,
|
||||||
isFirstTab?: boolean,
|
|
||||||
) {
|
) {
|
||||||
// Scroll to tabs if needed
|
// Scroll to tabs if needed
|
||||||
useEffectWithPrevDeps(([prevTabType, prevIsFirstTab]) => {
|
useEffectWithPrevDeps(([prevTabType]) => {
|
||||||
if (isFirstTab === prevIsFirstTab) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prevTabType && prevTabType !== tabType) {
|
if (prevTabType && prevTabType !== tabType) {
|
||||||
const container = containerRef.current!;
|
const container = containerRef.current!;
|
||||||
const tabsEl = container.querySelector<HTMLDivElement>('.TabList')!;
|
const tabsEl = container.querySelector<HTMLDivElement>('.TabList')!;
|
||||||
@ -38,7 +33,7 @@ export default function useProfileState(
|
|||||||
}, PROGRAMMATIC_SCROLL_TIMEOUT_MS);
|
}, PROGRAMMATIC_SCROLL_TIMEOUT_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [tabType, isFirstTab, onProfileStateChange, containerRef]);
|
}, [tabType, onProfileStateChange, containerRef]);
|
||||||
|
|
||||||
// Scroll to top
|
// Scroll to top
|
||||||
useEffectWithPrevDeps(([prevProfileState]) => {
|
useEffectWithPrevDeps(([prevProfileState]) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user