From a1b07fb4d88126ba66156e540f1e6f536fb43208 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Tue, 11 Aug 2020 15:09:21 -0600 Subject: [PATCH] Scroll to show new comments --- src/page/HomePage/Report/ReportHistoryView.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/page/HomePage/Report/ReportHistoryView.js b/src/page/HomePage/Report/ReportHistoryView.js index c7153a0fea37..03f72d86062a 100644 --- a/src/page/HomePage/Report/ReportHistoryView.js +++ b/src/page/HomePage/Report/ReportHistoryView.js @@ -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(); } @@ -140,7 +138,12 @@ class ReportHistoryView extends React.Component { } return ( - + { + this.historyListElement = el; + this.scrollToBottomWhenListSizeChanges(); + }} + > {_.map(filteredHistory, (item, index) => (