mirror of
https://github.com/vector-im/element-web.git
synced 2025-08-26 17:01:49 +02:00
Merge pull request #2631 from matrix-org/bwindels/roomlistfilterfix
update range when items size changes
This commit is contained in:
commit
5aa08a0f02
@ -62,8 +62,13 @@ export default class LazyRenderList extends React.Component {
|
|||||||
componentWillReceiveProps(props) {
|
componentWillReceiveProps(props) {
|
||||||
const state = this.state;
|
const state = this.state;
|
||||||
const range = LazyRenderList.getVisibleRangeFromProps(props);
|
const range = LazyRenderList.getVisibleRangeFromProps(props);
|
||||||
// only update state if the new range isn't contained by the old anymore
|
const intersectRange = range.expand(OVERFLOW_MARGIN);
|
||||||
if (!state.renderRange || !state.renderRange.contains(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)});
|
this.setState({renderRange: range.expand(OVERFLOW_ITEMS)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user