u
This commit is contained in:
@@ -139,7 +139,18 @@ class FillSpace extends Component {
|
|||||||
} else {
|
} else {
|
||||||
this.maxSeenCount = Math.max(this.maxSeenCount || 0, total);
|
this.maxSeenCount = Math.max(this.maxSeenCount || 0, total);
|
||||||
}
|
}
|
||||||
// Clamp current page when the item list shrinks (e.g. brand deleted).
|
if (this.props.resetKey !== undefined && this.props.resetKey !== prevProps.resetKey) {
|
||||||
|
if (this.state.currentPage !== 1) {
|
||||||
|
this._goToPage(1);
|
||||||
|
} else {
|
||||||
|
this.props.onPageChange?.(1, {
|
||||||
|
pageCount: Math.max(1, Math.ceil(total / Math.max(1, this.state.pageSize))),
|
||||||
|
pageSize: this.state.pageSize,
|
||||||
|
total,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Clamp current page when the item list shrinks (e.g. brand deleted) or trigger load for current page if items are missing.
|
||||||
if (
|
if (
|
||||||
Array.isArray(this.props.items) &&
|
Array.isArray(this.props.items) &&
|
||||||
this.props.items !== prevProps.items
|
this.props.items !== prevProps.items
|
||||||
@@ -155,6 +166,15 @@ class FillSpace extends Component {
|
|||||||
pageSize: this.state.pageSize,
|
pageSize: this.state.pageSize,
|
||||||
total,
|
total,
|
||||||
});
|
});
|
||||||
|
} else if (this.state.currentPage > 1) {
|
||||||
|
const offset = (this.state.currentPage - 1) * this.state.pageSize;
|
||||||
|
if (this.props.items.length > offset && this.props.items[offset] == null) {
|
||||||
|
this.props.onPageChange?.(this.state.currentPage, {
|
||||||
|
pageCount,
|
||||||
|
pageSize: this.state.pageSize,
|
||||||
|
total,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -411,6 +431,7 @@ class FillSpace extends Component {
|
|||||||
totalCount,
|
totalCount,
|
||||||
unfilteredCount,
|
unfilteredCount,
|
||||||
unfilteredTotal: propUnfilteredTotal,
|
unfilteredTotal: propUnfilteredTotal,
|
||||||
|
resetKey,
|
||||||
listRef,
|
listRef,
|
||||||
onPageChange,
|
onPageChange,
|
||||||
onWheel,
|
onWheel,
|
||||||
|
|||||||
Reference in New Issue
Block a user