From e215ca23a0b225bc715d9bbde12fecd36e7b0f75 Mon Sep 17 00:00:00 2001 From: Rickard Osser Date: Mon, 22 Jun 2026 14:38:09 +0200 Subject: [PATCH 1/2] Added 50 to items list both in the Grid-demo as well as in Grid. Fixed so Grid ipp will show selected value if set, otherwise fallback to 50 as it is default. --- demos/collection/grid.php | 2 +- src/Grid.php | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/demos/collection/grid.php b/demos/collection/grid.php index 1dd616cc05..28a407e3a2 100644 --- a/demos/collection/grid.php +++ b/demos/collection/grid.php @@ -105,4 +105,4 @@ }); // setting ipp with an array will add an ItemPerPageSelector to paginator -$grid->setIpp([10, 100, 1000]); +$grid->setIpp([10, 50, 100, 1000]); diff --git a/src/Grid.php b/src/Grid.php index b58d8e9f96..dd8aceee83 100644 --- a/src/Grid.php +++ b/src/Grid.php @@ -214,13 +214,18 @@ public function setIpp($ipp, $label = 'Items per page:'): void * * @return $this */ - public function addItemsPerPageSelector(array $items = [10, 100, 1000], $label = 'Items per page:') + public function addItemsPerPageSelector(array $items = [10, 50, 100, 1000], $label = 'Items per page:') { $ipp = (int) $this->container->stickyGet('ipp'); - if ($ipp) { + + /* + * If $ipp is 0 don't set $this->ipp to the first item as that always sets the viewed selection + * to the first item in the list. If we actually track the ipp in the app we want it to set and + * show the correct value, as it was before reload or other events, before this change it only set the selected ipp value but showed the first item. + * Default ipp in this class is 50, that will be showed when nothing is selected. + */ + if ($ipp > 0) { $this->ipp = $ipp; - } else { - $this->ipp = $items[0]; } $pageLength = ItemsPerPageSelector::addTo($this->paginator, ['pageLengthItems' => $items, 'label' => $label, 'currentIpp' => $this->ipp], ['afterPaginator']); From 6c8cdbd285c78534e57643f728e1ffac56ae15a7 Mon Sep 17 00:00:00 2001 From: Rickard Osser Date: Mon, 22 Jun 2026 14:59:23 +0200 Subject: [PATCH 2/2] Changed default IPP to use 10 as that is used in the tests-behat for IPP in grid.feature. --- src/Grid.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Grid.php b/src/Grid.php index dd8aceee83..a262f06612 100644 --- a/src/Grid.php +++ b/src/Grid.php @@ -48,7 +48,7 @@ class Grid extends View public $paginator; /** @var int Number of items per page to display. */ - public $ipp = 50; + public $ipp = 10; /** * Calling addActionButton will add a new column inside $table, and will be re-used