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';
66import IconCheveronDownBlue from 'assets/images/timeline-wall/cheveron-down-blue.svg' ;
77import { deleteEventById , approveEventById , rejectEventById } from 'services/timelineWall' ;
88import cn from 'classnames' ;
9+ import moment from 'moment' ;
910import _ from 'lodash' ;
1011import timelineActions from 'actions/timelineWall' ;
1112import LoadingIndicator from 'components/LoadingIndicator' ;
@@ -77,7 +78,21 @@ function TimelineWallContainer(props) {
7778 } , [ pendingApprovals ] ) ;
7879
7980 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+
8196 if ( target ) {
8297 const yOffset = - 10 ;
8398 const coordinate = target . getBoundingClientRect ( ) . top + window . pageYOffset + yOffset ;
You can’t perform that action at this time.
0 commit comments