Skip to content

Commit db7171d

Browse files
committed
Reset the pagination offset once it exactly hits the total
A stored offset equal to the total was still one past the last row, the same as being beyond it, but only ">" was checked - a filter that tightened the total to exactly the stored offset (rather than below it) queried a page that no longer existed and rendered empty.
1 parent 86ab16a commit db7171d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/Panel/DefaultLimitElement.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,11 @@ private function defineOffsetAndAmountOption(int &$offset, int &$amount): void
285285
$offset = (int) $persistent['offset'];
286286
$amount = (int) $persistent['amount'];
287287

288-
// Hotfix the offset - we also might want to store it persistent.
289-
// Another way would be to always stick on the "last" page when we hit the upper limit.
290-
if ($offset > $this->intTotal) {
288+
// A stored offset that no longer fits the current total - most commonly because a
289+
// filter was changed or tightened since - would otherwise query a page that does not
290+
// exist and render empty. ">=" rather than ">": an offset equal to the total is already
291+
// one past the last valid row, the same as being beyond it.
292+
if ($offset >= $this->intTotal) {
291293
$offset = 0;
292294
}
293295
}

0 commit comments

Comments
 (0)