mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG Reset GridFieldFilterHeader grid state when search is cleared (#9829)
This commit is contained in:
parent
54bdabd203
commit
0dd59a1e7b
@ -176,6 +176,7 @@ class GridFieldFilterHeader implements GridField_URLHandler, GridField_HTMLProvi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$state = $this->getState($gridField);
|
$state = $this->getState($gridField);
|
||||||
|
$state->Columns = [];
|
||||||
|
|
||||||
if ($actionName === 'filter') {
|
if ($actionName === 'filter') {
|
||||||
if (isset($data['filter'][$gridField->getName()])) {
|
if (isset($data['filter'][$gridField->getName()])) {
|
||||||
|
@ -118,4 +118,25 @@ class GridFieldFilterHeaderTest extends SapphireTest
|
|||||||
$this->assertEquals('place', $searchSchema->filters->Search__City);
|
$this->assertEquals('place', $searchSchema->filters->Search__City);
|
||||||
$this->assertEquals('testfield', $searchSchema->gridfield);
|
$this->assertEquals('testfield', $searchSchema->gridfield);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testHandleActionReset()
|
||||||
|
{
|
||||||
|
// Init Grid state with some pre-existing filters
|
||||||
|
$state = $this->gridField->State;
|
||||||
|
$state->GridFieldFilterHeader = [];
|
||||||
|
$state->GridFieldFilterHeader->Columns = [];
|
||||||
|
$state->GridFieldFilterHeader->Columns->Name = 'test';
|
||||||
|
|
||||||
|
$this->component->handleAction(
|
||||||
|
$this->gridField,
|
||||||
|
'reset',
|
||||||
|
[],
|
||||||
|
'{"GridFieldFilterHeader":{"Columns":{"Name":"test"}}}'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEmpty(
|
||||||
|
$state->GridFieldFilterHeader->Columns->toArray(),
|
||||||
|
'GridFieldFilterHeader::handleAction resets the gridstate filter when the user resets the search.'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user