Message List: Again fix scroll jump when closing chat on mobile
This commit is contained in:
parent
41c02d4e08
commit
414c88f345
@ -10,6 +10,8 @@ export default function usePrevDuringAnimation(current: any, duration?: number)
|
|||||||
const forceUpdate = useForceUpdate();
|
const forceUpdate = useForceUpdate();
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const isCurrentPresent = current !== undefined && current !== null;
|
const isCurrentPresent = current !== undefined && current !== null;
|
||||||
|
// eslint-disable-next-line no-null/no-null
|
||||||
|
const isPrevPresent = prev !== undefined && prev !== null;
|
||||||
|
|
||||||
if (isCurrentPresent && timeoutRef.current) {
|
if (isCurrentPresent && timeoutRef.current) {
|
||||||
clearTimeout(timeoutRef.current);
|
clearTimeout(timeoutRef.current);
|
||||||
@ -18,7 +20,7 @@ export default function usePrevDuringAnimation(current: any, duration?: number)
|
|||||||
|
|
||||||
useOnChange(() => {
|
useOnChange(() => {
|
||||||
// When `current` becomes empty
|
// When `current` becomes empty
|
||||||
if (duration && !isCurrentPresent && prev && !timeoutRef.current) {
|
if (duration && !isCurrentPresent && isPrevPresent && !timeoutRef.current) {
|
||||||
timeoutRef.current = window.setTimeout(() => {
|
timeoutRef.current = window.setTimeout(() => {
|
||||||
timeoutRef.current = undefined;
|
timeoutRef.current = undefined;
|
||||||
forceUpdate();
|
forceUpdate();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user