ScrollableList: only restore scroll position when navigating back
This commit is contained in:
parent
7b1190e6cd
commit
aecf539581
|
@ -1,4 +1,5 @@
|
||||||
import React, { useEffect, useRef } from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
import { Virtuoso, Components, VirtuosoProps, VirtuosoHandle, ListRange } from 'react-virtuoso';
|
import { Virtuoso, Components, VirtuosoProps, VirtuosoHandle, ListRange } from 'react-virtuoso';
|
||||||
|
|
||||||
import PullToRefresh from 'soapbox/components/pull-to-refresh';
|
import PullToRefresh from 'soapbox/components/pull-to-refresh';
|
||||||
|
@ -74,6 +75,7 @@ const ScrollableList = React.forwardRef<VirtuosoHandle, IScrollableList>(({
|
||||||
style = {},
|
style = {},
|
||||||
useWindowScroll = true,
|
useWindowScroll = true,
|
||||||
}, ref) => {
|
}, ref) => {
|
||||||
|
const history = useHistory();
|
||||||
const settings = useSettings();
|
const settings = useSettings();
|
||||||
const autoloadMore = settings.get('autoloadMore');
|
const autoloadMore = settings.get('autoloadMore');
|
||||||
|
|
||||||
|
@ -176,7 +178,7 @@ const ScrollableList = React.forwardRef<VirtuosoHandle, IScrollableList>(({
|
||||||
endReached={handleEndReached}
|
endReached={handleEndReached}
|
||||||
isScrolling={isScrolling => isScrolling && onScroll && onScroll()}
|
isScrolling={isScrolling => isScrolling && onScroll && onScroll()}
|
||||||
itemContent={renderItem}
|
itemContent={renderItem}
|
||||||
initialTopMostItemIndex={showLoading ? 0 : initialTopMostItemIndex || (scrollData ? { align: 'start', index: scrollData.index, offset: scrollData.offset } : 0)}
|
initialTopMostItemIndex={showLoading ? 0 : initialTopMostItemIndex || (scrollData && history.action === 'POP' ? { align: 'start', index: scrollData.index, offset: scrollData.offset } : 0)}
|
||||||
rangeChanged={handleRangeChange}
|
rangeChanged={handleRangeChange}
|
||||||
style={style}
|
style={style}
|
||||||
context={{
|
context={{
|
||||||
|
|
Loading…
Reference in New Issue