mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-11 15:47:09 -07:00
Fixed: restoring scroll position when going back to index page
This commit is contained in:
parent
e681469857
commit
1bc52d0138
9 changed files with 54 additions and 9 deletions
|
@ -408,7 +408,10 @@ class ArtistDetails extends Component {
|
||||||
name={icons.ARROW_UP}
|
name={icons.ARROW_UP}
|
||||||
size={30}
|
size={30}
|
||||||
title={'Go to artist listing'}
|
title={'Go to artist listing'}
|
||||||
to={'/'}
|
to={{
|
||||||
|
pathname: '/',
|
||||||
|
state: { restoreScrollPosition: true }
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<IconButton
|
<IconButton
|
||||||
|
|
|
@ -112,7 +112,8 @@ class ArtistIndexBanners extends Component {
|
||||||
items,
|
items,
|
||||||
sortKey,
|
sortKey,
|
||||||
bannerOptions,
|
bannerOptions,
|
||||||
jumpToCharacter
|
jumpToCharacter,
|
||||||
|
scrollTop
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -149,6 +150,10 @@ class ArtistIndexBanners extends Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._grid && scrollTop !== 0) {
|
||||||
|
this._grid.scrollToPosition({ scrollTop });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -307,6 +312,7 @@ ArtistIndexBanners.propTypes = {
|
||||||
sortKey: PropTypes.string,
|
sortKey: PropTypes.string,
|
||||||
bannerOptions: PropTypes.object.isRequired,
|
bannerOptions: PropTypes.object.isRequired,
|
||||||
jumpToCharacter: PropTypes.string,
|
jumpToCharacter: PropTypes.string,
|
||||||
|
scrollTop: PropTypes.number.isRequired,
|
||||||
scroller: PropTypes.instanceOf(Element).isRequired,
|
scroller: PropTypes.instanceOf(Element).isRequired,
|
||||||
showRelativeDates: PropTypes.bool.isRequired,
|
showRelativeDates: PropTypes.bool.isRequired,
|
||||||
shortDateFormat: PropTypes.string.isRequired,
|
shortDateFormat: PropTypes.string.isRequired,
|
||||||
|
|
|
@ -71,7 +71,8 @@ class ArtistIndexOverviews extends Component {
|
||||||
items,
|
items,
|
||||||
sortKey,
|
sortKey,
|
||||||
overviewOptions,
|
overviewOptions,
|
||||||
jumpToCharacter
|
jumpToCharacter,
|
||||||
|
scrollTop
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -103,6 +104,10 @@ class ArtistIndexOverviews extends Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._grid && scrollTop !== 0) {
|
||||||
|
this._grid.scrollToPosition({ scrollTop });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -112,7 +112,8 @@ class ArtistIndexPosters extends Component {
|
||||||
items,
|
items,
|
||||||
sortKey,
|
sortKey,
|
||||||
posterOptions,
|
posterOptions,
|
||||||
jumpToCharacter
|
jumpToCharacter,
|
||||||
|
scrollTop
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -149,6 +150,10 @@ class ArtistIndexPosters extends Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._grid && scrollTop !== 0) {
|
||||||
|
this._grid.scrollToPosition({ scrollTop });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -310,6 +315,7 @@ ArtistIndexPosters.propTypes = {
|
||||||
sortKey: PropTypes.string,
|
sortKey: PropTypes.string,
|
||||||
posterOptions: PropTypes.object.isRequired,
|
posterOptions: PropTypes.object.isRequired,
|
||||||
jumpToCharacter: PropTypes.string,
|
jumpToCharacter: PropTypes.string,
|
||||||
|
scrollTop: PropTypes.number.isRequired,
|
||||||
scroller: PropTypes.instanceOf(Element).isRequired,
|
scroller: PropTypes.instanceOf(Element).isRequired,
|
||||||
showRelativeDates: PropTypes.bool.isRequired,
|
showRelativeDates: PropTypes.bool.isRequired,
|
||||||
shortDateFormat: PropTypes.string.isRequired,
|
shortDateFormat: PropTypes.string.isRequired,
|
||||||
|
|
|
@ -83,7 +83,8 @@ class ArtistIndexTable extends Component {
|
||||||
showBanners,
|
showBanners,
|
||||||
isSmallScreen,
|
isSmallScreen,
|
||||||
onSortPress,
|
onSortPress,
|
||||||
scroller
|
scroller,
|
||||||
|
scrollTop
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -91,6 +92,7 @@ class ArtistIndexTable extends Component {
|
||||||
className={styles.tableContainer}
|
className={styles.tableContainer}
|
||||||
items={items}
|
items={items}
|
||||||
scrollIndex={this.state.scrollIndex}
|
scrollIndex={this.state.scrollIndex}
|
||||||
|
scrollTop={scrollTop}
|
||||||
isSmallScreen={isSmallScreen}
|
isSmallScreen={isSmallScreen}
|
||||||
scroller={scroller}
|
scroller={scroller}
|
||||||
rowHeight={showBanners ? 70 : 38}
|
rowHeight={showBanners ? 70 : 38}
|
||||||
|
@ -120,6 +122,7 @@ ArtistIndexTable.propTypes = {
|
||||||
sortDirection: PropTypes.oneOf(sortDirections.all),
|
sortDirection: PropTypes.oneOf(sortDirections.all),
|
||||||
showBanners: PropTypes.bool.isRequired,
|
showBanners: PropTypes.bool.isRequired,
|
||||||
jumpToCharacter: PropTypes.string,
|
jumpToCharacter: PropTypes.string,
|
||||||
|
scrollTop: PropTypes.number,
|
||||||
scroller: PropTypes.instanceOf(Element).isRequired,
|
scroller: PropTypes.instanceOf(Element).isRequired,
|
||||||
isSmallScreen: PropTypes.bool.isRequired,
|
isSmallScreen: PropTypes.bool.isRequired,
|
||||||
onSortPress: PropTypes.func.isRequired
|
onSortPress: PropTypes.func.isRequired
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Link extends Component {
|
||||||
const linkProps = { target };
|
const linkProps = { target };
|
||||||
let el = component;
|
let el = component;
|
||||||
|
|
||||||
if (to) {
|
if (to && typeof to === 'string') {
|
||||||
if ((/\w+?:\/\//).test(to)) {
|
if ((/\w+?:\/\//).test(to)) {
|
||||||
el = 'a';
|
el = 'a';
|
||||||
linkProps.href = to;
|
linkProps.href = to;
|
||||||
|
@ -56,6 +56,18 @@ class Link extends Component {
|
||||||
linkProps.to = `${window.Lidarr.urlBase}/${to.replace(/^\//, '')}`;
|
linkProps.to = `${window.Lidarr.urlBase}/${to.replace(/^\//, '')}`;
|
||||||
linkProps.target = target;
|
linkProps.target = target;
|
||||||
}
|
}
|
||||||
|
} else if (to && typeof to === 'object') {
|
||||||
|
el = RouterLink;
|
||||||
|
linkProps.target = target;
|
||||||
|
if (to.pathname.startsWith(`${window.Lidarr.urlBase}/`)) {
|
||||||
|
linkProps.to = to;
|
||||||
|
} else {
|
||||||
|
const pathname = `${window.Lidarr.urlBase}/${to.pathname.replace(/^\//, '')}`;
|
||||||
|
linkProps.to = {
|
||||||
|
...to,
|
||||||
|
pathname
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (el === 'button' || el === 'input') {
|
if (el === 'button' || el === 'input') {
|
||||||
|
@ -86,7 +98,7 @@ class Link extends Component {
|
||||||
Link.propTypes = {
|
Link.propTypes = {
|
||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
||||||
to: PropTypes.string,
|
to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
||||||
target: PropTypes.string,
|
target: PropTypes.string,
|
||||||
isDisabled: PropTypes.bool,
|
isDisabled: PropTypes.bool,
|
||||||
noRouter: PropTypes.bool,
|
noRouter: PropTypes.bool,
|
||||||
|
|
|
@ -53,7 +53,10 @@ class PageHeader extends Component {
|
||||||
<div className={styles.logoContainer}>
|
<div className={styles.logoContainer}>
|
||||||
<Link
|
<Link
|
||||||
className={styles.logoLink}
|
className={styles.logoLink}
|
||||||
to={`${window.Lidarr.urlBase}/`}
|
to={{
|
||||||
|
pathname: '/',
|
||||||
|
state: { restoreScrollPosition: true }
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
className={styles.logo}
|
className={styles.logo}
|
||||||
|
|
|
@ -47,6 +47,7 @@ class VirtualTable extends Component {
|
||||||
const {
|
const {
|
||||||
items,
|
items,
|
||||||
scrollIndex,
|
scrollIndex,
|
||||||
|
scrollTop,
|
||||||
onRecompute
|
onRecompute
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
@ -68,6 +69,10 @@ class VirtualTable extends Component {
|
||||||
columnIndex: 0
|
columnIndex: 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._grid && scrollTop !== undefined && scrollTop !== 0) {
|
||||||
|
this._grid.scrollToPosition({ scrollTop });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -95,6 +100,7 @@ class VirtualTable extends Component {
|
||||||
className,
|
className,
|
||||||
items,
|
items,
|
||||||
scroller,
|
scroller,
|
||||||
|
scrollTop: ignored,
|
||||||
header,
|
header,
|
||||||
headerHeight,
|
headerHeight,
|
||||||
rowHeight,
|
rowHeight,
|
||||||
|
@ -179,6 +185,7 @@ VirtualTable.propTypes = {
|
||||||
className: PropTypes.string.isRequired,
|
className: PropTypes.string.isRequired,
|
||||||
items: PropTypes.arrayOf(PropTypes.object).isRequired,
|
items: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
scrollIndex: PropTypes.number,
|
scrollIndex: PropTypes.number,
|
||||||
|
scrollTop: PropTypes.number,
|
||||||
scroller: PropTypes.instanceOf(Element).isRequired,
|
scroller: PropTypes.instanceOf(Element).isRequired,
|
||||||
header: PropTypes.node.isRequired,
|
header: PropTypes.node.isRequired,
|
||||||
headerHeight: PropTypes.number.isRequired,
|
headerHeight: PropTypes.number.isRequired,
|
||||||
|
|
|
@ -8,7 +8,7 @@ function withScrollPosition(WrappedComponent, scrollPositionKey) {
|
||||||
history
|
history
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const scrollTop = history.action === 'POP' ?
|
const scrollTop = history.action === 'POP' || (history.location.state && history.location.state.restoreScrollPosition) ?
|
||||||
scrollPositions[scrollPositionKey] :
|
scrollPositions[scrollPositionKey] :
|
||||||
0;
|
0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue