Skip to content

Commit e49067d

Browse files
Merge remote-tracking branch 'remotes/origin/#530' into allfunctionality
2 parents e2362bc + bcebc5e commit e49067d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

js/components/tracking/trackingModal.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { memo, useCallback, useEffect } from 'react';
1+
import React, { memo, useCallback, useEffect, useRef } from 'react';
22
import { useSelector, useDispatch } from 'react-redux';
33
import Modal from '../common/Modal';
44
import { Grid, makeStyles, IconButton, Tooltip } from '@material-ui/core';
@@ -33,6 +33,7 @@ const useStyles = makeStyles(theme => ({
3333
export const TrackingModal = memo(({ openModal, onModalClose }) => {
3434
const classes = useStyles();
3535
const dispatch = useDispatch();
36+
const bottomRef = useRef();
3637

3738
const actionList = useSelector(state => state.trackingReducers.project_actions_list);
3839
const orderedActionList = (actionList && actionList.sort((a, b) => a.timestamp - b.timestamp)) || [];
@@ -43,6 +44,16 @@ export const TrackingModal = memo(({ openModal, onModalClose }) => {
4344
}
4445
}, [dispatch, openModal]);
4546

47+
const scrollToBottom = () => {
48+
if (bottomRef.current != null) {
49+
bottomRef.current.scrollIntoView({
50+
behavior: 'auto',
51+
block: 'nearest',
52+
inline: 'nearest'
53+
});
54+
}
55+
};
56+
4657
useEffect(() => {
4758
loadAllActions();
4859
}, [loadAllActions]);
@@ -79,6 +90,12 @@ export const TrackingModal = memo(({ openModal, onModalClose }) => {
7990
}
8091
})}
8192
</Timeline>
93+
<div
94+
ref={el => {
95+
bottomRef.current = el;
96+
scrollToBottom();
97+
}}
98+
></div>
8299
</div>
83100
</div>
84101
</Grid>

0 commit comments

Comments
 (0)