TagSpaces is an offline, open source, document manager with tagging support
fix scroll in pagination on folder change (#1502)
Stanimir197285bbf69d
diff --git a/app/perspectives/grid-perspective/components/GridPagination.tsx b/app/perspectives/grid-perspective/components/GridPagination.tsxindex 2f716b098..49441f1e0 100644--- a/app/perspectives/grid-perspective/components/GridPagination.tsx+++ b/app/perspectives/grid-perspective/components/GridPagination.tsx@@ -16,7 +16,7 @@**/-import React, { useState, useEffect } from 'react';+import React, { useState, useEffect, useRef } from 'react';import { connect } from 'react-redux';import Typography from '@material-ui/core/Typography';import Pagination from '@material-ui/lab/Pagination';@@ -62,10 +62,14 @@ const GridPagination = (props: Props) => {currentPage} = props;let { files } = props;+ const containerEl = useRef(null);const [page, setPage] = useState(currentPage);useEffect(() => {setPage(props.currentPage);+ if (containerEl && containerEl.current) {+ containerEl.current.scrollTop = 0;+ }}, [props.currentLocationPath,props.currentDirectoryPath,@@ -73,8 +77,10 @@ const GridPagination = (props: Props) => {]);const handleChange = (event, value) => {- // props.currentPage = value;setPage(value);+ if (containerEl && containerEl.current) {+ containerEl.current.scrollTop = 0;+ }};let paginationCount = 10;@@ -89,6 +95,7 @@ const GridPagination = (props: Props) => {return (<div+ ref={containerEl}onContextMenu={(e: React.MouseEvent<HTMLDivElement>) =>props.onContextMenu(e)}@@ -102,9 +109,6 @@ const GridPagination = (props: Props) => {<divclassName={className}style={style}- /* ref={ref => {- gridRef = ref;- }} */data-tid="perspectiveGridFileTable">{page === 1 && directories.map(entry => renderCell(entry))}