Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll to show new comments #63

Merged
merged 1 commit into from
Aug 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/page/HomePage/Report/ReportHistoryView.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,12 @@ class ReportHistoryView extends React.Component {
* This function is triggered from the ref callback for the scrollview. That way it can be scrolled once all the
* items have been rendered. If the number of items in our history have changed since it was last rendered, then
* scroll the list to the end.
*
* @param {object} el
*/
scrollToBottomWhenListSizeChanges(el) {
if (el) {
scrollToBottomWhenListSizeChanges() {
if (this.historyListElement) {
const filteredHistory = this.getFilteredReportHistory();
if (this.previousReportHistoryLength < filteredHistory.length) {
el.scrollToEnd({animated: false});
this.historyListElement.scrollToEnd({animated: false});
this.recordMaxAction();
}

Expand All @@ -140,7 +138,12 @@ class ReportHistoryView extends React.Component {
}

return (
<ScrollView ref={this.scrollToBottomWhenListSizeChanges}>
<ScrollView
ref={(el) => {
this.historyListElement = el;
this.scrollToBottomWhenListSizeChanges();
}}
>
{_.map(filteredHistory, (item, index) => (
<ReportHistoryItem
key={item.sequenceNumber}
Expand Down