Skip to content

Commit 28f678b

Browse files
authored
Merge pull request #6689 from nursoltan-s/timeline-wall-final-fix
sort events descending order
2 parents 98cef23 + ab735ad commit 28f678b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ function TimelineWallContainer(props) {
7777
}, [pendingApprovals]);
7878

7979
useEffect(() => {
80-
const target = document.getElementById(`${selectedFilterValue.year}-${selectedFilterValue.month}`);
80+
const target = document.getElementById(`${selectedFilterValue.year}-${(selectedFilterValue.month + 1).toString().padStart(2, '0')}`);
8181
if (target) {
82-
target.scrollIntoView({ behavior: 'smooth' }, true);
82+
const yOffset = -10;
83+
const coordinate = target.getBoundingClientRect().top + window.pageYOffset + yOffset;
84+
window.scrollTo({ top: coordinate, behavior: 'smooth' });
8385
} else {
8486
window.scrollTo({ top: 0, behavior: 'smooth' });
8587
}
@@ -104,6 +106,8 @@ function TimelineWallContainer(props) {
104106
});
105107
};
106108

109+
const sortedEvents = _.orderBy(events, ['eventDate'], ['desc']);
110+
107111
return (
108112
<div styleName="container">
109113
<div styleName={isAdmin ? 'header header-admin' : 'header'}>
@@ -153,7 +157,7 @@ function TimelineWallContainer(props) {
153157
<TimelineEvents
154158
isAuthenticated={!!authToken}
155159
isAdmin={isAdmin}
156-
events={events}
160+
events={sortedEvents}
157161
styleName={cn('tab-content', { hide: tab === 1, 'is-admin': role === 'Admin user' })}
158162
removeEvent={removeEvent}
159163
showRightFilterMobile={showRightFilterMobile}

0 commit comments

Comments
 (0)