Skip to content

Commit f382cb3

Browse files
authored
Merge pull request #6695 from nursoltan-s/timeline-wall-final-fix
fix filter nav
2 parents 28f678b + edeb7b0 commit f382cb3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/shared/containers/timeline-wall/index.jsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import TopBannerMobile from 'assets/images/timeline-wall/top-banner-mobile.png';
66
import IconCheveronDownBlue from 'assets/images/timeline-wall/cheveron-down-blue.svg';
77
import { deleteEventById, approveEventById, rejectEventById } from 'services/timelineWall';
88
import cn from 'classnames';
9+
import moment from 'moment';
910
import _ from 'lodash';
1011
import timelineActions from 'actions/timelineWall';
1112
import 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;

0 commit comments

Comments
 (0)