File tree 2 files changed +8
-2
lines changed
2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,11 @@ import { OverlayScrollContext } from "context/OverlayScrollContext";
4
4
export const useScrollTop = ( ) => {
5
5
const osInstanceRef = useContext ( OverlayScrollContext ) ;
6
6
7
- const scrollTop = ( ) => {
8
- osInstanceRef ?. current ?. osInstance ( ) . elements ( ) . viewport . scroll ( { top : 0 } ) ;
7
+ const scrollTop = ( smooth = false ) => {
8
+ osInstanceRef ?. current
9
+ ?. osInstance ( )
10
+ . elements ( )
11
+ . viewport . scroll ( { top : 0 , behavior : smooth ? "smooth" : "auto" } ) ;
9
12
} ;
10
13
11
14
return scrollTop ;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import JurorCard from "../Home/TopJurors/JurorCard";
15
15
import { ListContainer , StyledLabel } from "../Home/TopJurors" ;
16
16
import Header from "../Home/TopJurors/Header" ;
17
17
import { decodeURIFilter } from "utils/uri" ;
18
+ import { useScrollTop } from "hooks/useScrollTop" ;
18
19
19
20
interface IDisplayJurors {
20
21
totalLeaderboardJurors : number ;
@@ -28,6 +29,7 @@ const StyledPagination = styled(StandardPagination)`
28
29
29
30
const DisplayJurors : React . FC < IDisplayJurors > = ( { totalLeaderboardJurors } ) => {
30
31
const { page, order, filter } = useParams ( ) ;
32
+ const scrollTop = useScrollTop ( ) ;
31
33
const { id : searchValue } = decodeURIFilter ( filter ?? "all" ) ;
32
34
const navigate = useNavigate ( ) ;
33
35
const isDesktop = useIsDesktop ( ) ;
@@ -62,6 +64,7 @@ const DisplayJurors: React.FC<IDisplayJurors> = ({ totalLeaderboardJurors }) =>
62
64
) ;
63
65
64
66
const handlePageChange = ( newPage : number ) => {
67
+ scrollTop ( true ) ;
65
68
navigate ( `/jurors/${ newPage } /${ order } /${ filter } ` ) ;
66
69
} ;
67
70
You can’t perform that action at this time.
0 commit comments