From a1a82e48d99389718e1a98f61c06819f88f4c85d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 13 Feb 2019 20:21:17 +0100 Subject: [PATCH] update range when items size changes --- src/components/views/elements/LazyRenderList.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/views/elements/LazyRenderList.js b/src/components/views/elements/LazyRenderList.js index b7916510a4..1c1cc127d6 100644 --- a/src/components/views/elements/LazyRenderList.js +++ b/src/components/views/elements/LazyRenderList.js @@ -62,8 +62,13 @@ export default class LazyRenderList extends React.Component { componentWillReceiveProps(props) { const state = this.state; const range = LazyRenderList.getVisibleRangeFromProps(props); - // only update state if the new range isn't contained by the old anymore - if (!state.renderRange || !state.renderRange.contains(range.expand(OVERFLOW_MARGIN))) { + const intersectRange = range.expand(OVERFLOW_MARGIN); + + const prevSize = this.props.items ? this.props.items.length : 0; + const listHasChangedSize = props.items.length !== prevSize; + // only update renderRange if the list has shrunk/grown and we need to adjust padding or + // if the new range isn't contained by the old anymore + if (listHasChangedSize || !state.renderRange || !state.renderRange.contains(intersectRange)) { this.setState({renderRange: range.expand(OVERFLOW_ITEMS)}); } }