From a820f3d3ca991d64bf7f8d0b4a09b4de22d1203f Mon Sep 17 00:00:00 2001 From: ta264 Date: Tue, 29 Mar 2022 21:27:44 +0100 Subject: [PATCH] Fixed: Jumpbar after going back to artist index page --- .../Artist/Index/Banners/ArtistIndexBanners.js | 14 +++++++++----- .../Artist/Index/Overview/ArtistIndexOverviews.js | 15 +++++++++------ .../Artist/Index/Posters/ArtistIndexPosters.js | 15 +++++++++------ frontend/src/Components/Table/VirtualTable.js | 15 +++++++++------ 4 files changed, 36 insertions(+), 23 deletions(-) diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBanners.js b/frontend/src/Artist/Index/Banners/ArtistIndexBanners.js index 919f4ed97..be3cdb502 100644 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBanners.js +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBanners.js @@ -100,7 +100,8 @@ class ArtistIndexBanners extends Component { columnCount: 1, bannerWidth: 476, bannerHeight: 88, - rowHeight: calculateRowHeight(88, null, props.isSmallScreen, {}) + rowHeight: calculateRowHeight(88, null, props.isSmallScreen, {}), + scrollRestored: false }; this._isInitialized = false; @@ -120,7 +121,8 @@ class ArtistIndexBanners extends Component { width, columnWidth, columnCount, - rowHeight + rowHeight, + scrollRestored } = this.state; if (prevProps.sortKey !== sortKey || @@ -138,6 +140,11 @@ class ArtistIndexBanners 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); @@ -151,9 +158,6 @@ class ArtistIndexBanners extends Component { } } - if (this._grid && scrollTop !== 0) { - this._grid.scrollToPosition({ scrollTop }); - } } // diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.js b/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.js index 313bee6a1..7b865569e 100644 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.js +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.js @@ -60,7 +60,8 @@ class ArtistIndexOverviews extends Component { columnCount: 1, posterWidth: 238, posterHeight: 238, - rowHeight: calculateRowHeight(238, null, props.isSmallScreen, {}) + rowHeight: calculateRowHeight(238, null, props.isSmallScreen, {}), + scrollRestored: false }; this._grid = null; @@ -77,7 +78,8 @@ class ArtistIndexOverviews extends Component { const { width, - rowHeight + rowHeight, + scrollRestored } = this.state; if (prevProps.sortKey !== sortKey || @@ -93,6 +95,11 @@ class ArtistIndexOverviews 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); @@ -104,10 +111,6 @@ class ArtistIndexOverviews extends Component { }); } } - - if (this._grid && scrollTop !== 0) { - this._grid.scrollToPosition({ scrollTop }); - } } // diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPosters.js b/frontend/src/Artist/Index/Posters/ArtistIndexPosters.js index ae67cae62..db54e4108 100644 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPosters.js +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPosters.js @@ -100,7 +100,8 @@ class ArtistIndexPosters extends Component { columnCount: 1, posterWidth: 238, posterHeight: 238, - rowHeight: calculateRowHeight(238, null, props.isSmallScreen, {}) + rowHeight: calculateRowHeight(238, null, props.isSmallScreen, {}), + scrollRestored: false }; this._isInitialized = false; @@ -122,7 +123,8 @@ class ArtistIndexPosters extends Component { width, columnWidth, columnCount, - rowHeight + rowHeight, + scrollRestored } = this.state; if (prevProps.sortKey !== sortKey || @@ -140,6 +142,11 @@ class ArtistIndexPosters 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); @@ -152,10 +159,6 @@ class ArtistIndexPosters extends Component { }); } } - - if (this._grid && scrollTop !== 0) { - this._grid.scrollToPosition({ scrollTop }); - } } // diff --git a/frontend/src/Components/Table/VirtualTable.js b/frontend/src/Components/Table/VirtualTable.js index e5b012886..4a597e795 100644 --- a/frontend/src/Components/Table/VirtualTable.js +++ b/frontend/src/Components/Table/VirtualTable.js @@ -37,7 +37,8 @@ class VirtualTable extends Component { super(props, context); this.state = { - width: 0 + width: 0, + scrollRestored: false }; this._grid = null; @@ -52,7 +53,8 @@ class VirtualTable extends Component { } = this.props; const { - width + width, + scrollRestored } = this.state; if (this._grid && @@ -63,16 +65,17 @@ class VirtualTable extends Component { this._grid.recomputeGridSize(); } + if (this._grid && scrollTop !== undefined && scrollTop !== 0 && !scrollRestored) { + this.setState({ scrollRestored: true }); + this._grid.scrollToPosition({ scrollTop }); + } + if (scrollIndex != null && scrollIndex !== prevProps.scrollIndex) { this._grid.scrollToCell({ rowIndex: scrollIndex, columnIndex: 0 }); } - - if (this._grid && scrollTop !== undefined && scrollTop !== 0) { - this._grid.scrollToPosition({ scrollTop }); - } } //