FIX Ensuring pagination buttons have a consistent state to work off of (#8957)

This commit is contained in:
Guy Marriott 2019-05-06 14:42:25 +12:00 committed by Aaron Carlino
parent 8ee50d2ba7
commit 856e841955

View File

@ -513,9 +513,12 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
private function getAdjacentRecordID($offset)
{
$gridField = $this->getGridField();
$gridStateStr = $this->getRequest()->requestVar('gridState');
$list = $gridField->getManipulatedList();
$state = $gridField->getState(false);
$state->setValue($gridStateStr);
$gridStateStr = $this->getRequest()->requestVar('gridState');
if (!empty($gridStateStr)) {
$state->setValue($gridStateStr);
}
$data = $state->getData();
$paginator = $data->getData('GridFieldPaginator');
if (!$paginator) {
@ -528,7 +531,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
$limit = $itemsPerPage + 2;
$limitOffset = max(0, $itemsPerPage * ($currentPage-1) -1);
$map = $gridField->getManipulatedList()->limit($limit, $limitOffset)->column('ID');
$map = $list->limit($limit, $limitOffset)->column('ID');
$index = array_search($this->record->ID, $map);
return isset($map[$index+$offset]) ? $map[$index+$offset] : false;
}