File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
src/shared/containers/timeline-wall Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import TopBannerMobile from 'assets/images/timeline-wall/top-banner-mobile.png';
6
6
import IconCheveronDownBlue from 'assets/images/timeline-wall/cheveron-down-blue.svg' ;
7
7
import { deleteEventById , approveEventById , rejectEventById } from 'services/timelineWall' ;
8
8
import cn from 'classnames' ;
9
+ import moment from 'moment' ;
9
10
import _ from 'lodash' ;
10
11
import timelineActions from 'actions/timelineWall' ;
11
12
import LoadingIndicator from 'components/LoadingIndicator' ;
@@ -77,7 +78,21 @@ function TimelineWallContainer(props) {
77
78
} , [ pendingApprovals ] ) ;
78
79
79
80
useEffect ( ( ) => {
80
- const target = document . getElementById ( `${ selectedFilterValue . year } -${ ( selectedFilterValue . month + 1 ) . toString ( ) . padStart ( 2 , '0' ) } ` ) ;
81
+ const currentYear = selectedFilterValue . year ;
82
+ const currentMonth = selectedFilterValue . month ;
83
+ const maxYear = 2032 ;
84
+ let target ;
85
+ let date = moment ( `${ currentYear } -${ currentMonth + 1 } ` ) . format ( 'YYYY-MM' ) ;
86
+
87
+ while ( ! target ) {
88
+ target = document . getElementById ( `${ moment ( date ) . year ( ) } -${ ( moment ( date ) . month ( ) ) . toString ( ) . padStart ( 2 , '0' ) } ` ) ;
89
+
90
+ if ( target || ! moment ( date ) . isValid ( ) || moment ( date ) . year ( ) > maxYear ) {
91
+ break ;
92
+ }
93
+ date = moment ( date ) . add ( 1 , 'months' ) . format ( 'YYYY-MM' ) ;
94
+ }
95
+
81
96
if ( target ) {
82
97
const yOffset = - 10 ;
83
98
const coordinate = target . getBoundingClientRect ( ) . top + window . pageYOffset + yOffset ;
You can’t perform that action at this time.
0 commit comments