Refactor Artist index to use react-window

(cherry picked from commit d022679b7dcbce3cec98e6a1fd0879e3c0d92523)

Fixed: Restoring scroll position when going back/forward to artist list

(cherry picked from commit 5aad84dba453c42b4b5a9eac43deecf91a98f4f6)
This commit is contained in:
Mark McDowall 2023-01-05 18:20:49 -08:00 committed by Bogdan
commit f509ca0f72
117 changed files with 4704 additions and 5511 deletions

View file

@ -27,6 +27,8 @@ class UnmappedFilesTable extends Component {
constructor(props, context) {
super(props, context);
this.scrollerRef = React.createRef();
this.state = {
scroller: null,
allSelected: false,
@ -65,13 +67,6 @@ class UnmappedFilesTable extends Component {
}
}
//
// Control
setScrollerRef = (ref) => {
this.setState({ scroller: ref });
};
getSelectedIds = () => {
if (this.state.allUnselected) {
return [];
@ -184,7 +179,6 @@ class UnmappedFilesTable extends Component {
} = this.props;
const {
scroller,
allSelected,
allUnselected,
selectedState
@ -227,9 +221,7 @@ class UnmappedFilesTable extends Component {
</PageToolbarSection>
</PageToolbar>
<PageContentBody
registerScroller={this.setScrollerRef}
>
<PageContentBody ref={this.scrollerRef} >
{
isFetching && !isPopulated &&
<LoadingIndicator />
@ -243,11 +235,14 @@ class UnmappedFilesTable extends Component {
}
{
isPopulated && !error && !!items.length && scroller &&
isPopulated &&
!error &&
!!items.length &&
this.scrollerRef.current ?
<VirtualTable
items={items}
columns={columns}
scroller={scroller}
scroller={this.scrollerRef.current}
isSmallScreen={false}
overscanRowCount={10}
rowRenderer={this.rowRenderer}
@ -266,7 +261,8 @@ class UnmappedFilesTable extends Component {
selectedState={selectedState}
sortKey={sortKey}
sortDirection={sortDirection}
/>
/> :
null
}
</PageContentBody>
</PageContent>