From b96eb762ae589ffa825490b062b0c67a4c3ef0bf Mon Sep 17 00:00:00 2001 From: seb Date: Wed, 14 Oct 2026 00:22:04 +0200 Subject: [PATCH] u --- src/FillSpace.jsx | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/FillSpace.jsx b/src/FillSpace.jsx index 260888b..65e17a3 100644 --- a/src/FillSpace.jsx +++ b/src/FillSpace.jsx @@ -139,7 +139,18 @@ class FillSpace extends Component { } else { 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 ( Array.isArray(this.props.items) && this.props.items !== prevProps.items @@ -155,6 +166,15 @@ class FillSpace extends Component { pageSize: this.state.pageSize, 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, unfilteredCount, unfilteredTotal: propUnfilteredTotal, + resetKey, listRef, onPageChange, onWheel,