Skip to content

Commit 1076790

Browse files
Fix batched rendering when mcvp adjustment changes
1 parent ed156ff commit 1076790

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/virtualized-lists/Lists/VirtualizedList.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,10 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
544544
);
545545

546546
if (maintainVisibleContentPositionAdjustment != null) {
547+
console.log(
548+
'maintainVisibleContentPositionAdjustment',
549+
maintainVisibleContentPositionAdjustment,
550+
);
547551
renderMask.addCells({
548552
first:
549553
cellsAroundViewport.first +
@@ -1133,7 +1137,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
11331137
}
11341138
}
11351139

1136-
componentDidUpdate(prevProps: Props) {
1140+
componentDidUpdate(prevProps: Props, prevState: State) {
11371141
const {data, extraData} = this.props;
11381142
if (data !== prevProps.data || extraData !== prevProps.extraData) {
11391143
// clear the viewableIndices cache to also trigger
@@ -1155,6 +1159,15 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
11551159
if (hiPriInProgress) {
11561160
this._hiPriInProgress = false;
11571161
}
1162+
1163+
// Make sure to cancel any pending updates if maintainVisibleContentPositionAdjustment
1164+
// changed since they are now invalid.
1165+
if (
1166+
prevState.maintainVisibleContentPositionAdjustment !==
1167+
this.state.maintainVisibleContentPositionAdjustment
1168+
) {
1169+
this._updateCellsToRenderBatcher.dispose({abort: true});
1170+
}
11581171
}
11591172

11601173
_averageCellLength = 0;

0 commit comments

Comments
 (0)