1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-22 22:16:13 -04:00

Fixed: Restoring scroll position when going back to index page

This commit is contained in:
ta264
2021-05-06 21:49:33 +01:00
committed by Mark McDowall
parent 7c74d19515
commit 99843d2876
5 changed files with 40 additions and 10 deletions
@@ -60,7 +60,8 @@ class SeriesIndexOverviews extends Component {
columnCount: 1,
posterWidth: 162,
posterHeight: 238,
rowHeight: calculateRowHeight(238, null, props.isSmallScreen, {})
rowHeight: calculateRowHeight(238, null, props.isSmallScreen, {}),
scrollRestored: false
};
this._grid = null;
@@ -72,12 +73,14 @@ class SeriesIndexOverviews extends Component {
sortKey,
overviewOptions,
jumpToCharacter,
scrollTop,
isSmallScreen
} = this.props;
const {
width,
rowHeight
rowHeight,
scrollRestored
} = this.state;
if (prevProps.sortKey !== sortKey ||
@@ -97,6 +100,11 @@ class SeriesIndexOverviews extends Component {
this._grid.recomputeGridSize();
}
if (this._grid && scrollTop !== 0 && !scrollRestored) {
this.setState({ scrollRestored: true });
this._grid.scrollToPosition({ scrollTop });
}
if (jumpToCharacter != null && jumpToCharacter !== prevProps.jumpToCharacter) {
const index = getIndexOfFirstCharacter(items, jumpToCharacter);
@@ -255,6 +263,7 @@ SeriesIndexOverviews.propTypes = {
items: PropTypes.arrayOf(PropTypes.object).isRequired,
sortKey: PropTypes.string,
overviewOptions: PropTypes.object.isRequired,
scrollTop: PropTypes.number.isRequired,
jumpToCharacter: PropTypes.string,
scroller: PropTypes.instanceOf(Element).isRequired,
showRelativeDates: PropTypes.bool.isRequired,