@@ -7,6 +7,7 @@ import IconCheveronDownBlue from 'assets/images/timeline-wall/cheveron-down-blue
7
7
import { deleteEventById , approveEventById , rejectEventById } from 'services/timelineWall' ;
8
8
import cn from 'classnames' ;
9
9
import moment from 'moment' ;
10
+ import { useMediaQuery } from 'react-responsive' ;
10
11
import _ from 'lodash' ;
11
12
import timelineActions from 'actions/timelineWall' ;
12
13
import LoadingIndicator from 'components/LoadingIndicator' ;
@@ -40,6 +41,9 @@ function TimelineWallContainer(props) {
40
41
41
42
const role = 'Admin User' ;
42
43
const authToken = _ . get ( auth , 'tokenV3' ) ;
44
+ const isMobile = useMediaQuery ( {
45
+ query : '(max-device-width: 768px)' ,
46
+ } ) ;
43
47
44
48
useEffect ( ( ) => {
45
49
if ( authToken ) {
@@ -79,7 +83,7 @@ function TimelineWallContainer(props) {
79
83
80
84
useEffect ( ( ) => {
81
85
const currentYear = selectedFilterValue . year ;
82
- const currentMonth = selectedFilterValue . month ;
86
+ const currentMonth = Math . max ( selectedFilterValue . month , 0 ) ;
83
87
const maxYear = 2032 ;
84
88
let target ;
85
89
let date = moment ( `${ currentYear } -${ currentMonth + 1 } ` ) . format ( 'YYYY-MM' ) ;
@@ -96,7 +100,11 @@ function TimelineWallContainer(props) {
96
100
if ( target ) {
97
101
const yOffset = - 10 ;
98
102
const coordinate = target . getBoundingClientRect ( ) . top + window . pageYOffset + yOffset ;
99
- window . scrollTo ( { top : coordinate , behavior : 'smooth' } ) ;
103
+ if ( isMobile ) {
104
+ setTimeout ( target . scrollTo ( ) , 100 ) ;
105
+ } else {
106
+ window . scrollTo ( { top : coordinate , behavior : 'smooth' } ) ;
107
+ }
100
108
} else {
101
109
window . scrollTo ( { top : 0 , behavior : 'smooth' } ) ;
102
110
}
0 commit comments