Skip to content

Commit

Permalink
fix: errors when disabling filtering on data table types with filters…
Browse files Browse the repository at this point in the history
… defined
  • Loading branch information
Kreyu committed Jun 15, 2023
1 parent 2dde783 commit 26ad423
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/DataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function getPaginationData(): PaginationData
return $this->paginationData;
}

public function getFiltrationData(): FiltrationData
public function getFiltrationData(): ?FiltrationData
{
return $this->filtrationData;
}
Expand Down Expand Up @@ -308,7 +308,7 @@ public function isExporting(): bool

public function hasActiveFilters(): bool
{
return $this->filtrationData->hasActiveFilters();
return (bool) $this->filtrationData?->hasActiveFilters();
}

public function handleRequest(mixed $request): void
Expand Down
2 changes: 1 addition & 1 deletion src/DataTableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getSortingData(): SortingData;

public function getPaginationData(): PaginationData;

public function getFiltrationData(): FiltrationData;
public function getFiltrationData(): ?FiltrationData;

public function getPersonalizationData(): PersonalizationData;

Expand Down
4 changes: 4 additions & 0 deletions src/Type/DataTableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ private function createFilterViews(DataTableView $view, DataTableInterface $data
{
$filters = [];

if (!$dataTable->getConfig()->isFiltrationEnabled()) {
return [];
}

foreach ($dataTable->getConfig()->getFilters() as $filter) {
$data = $dataTable->getFiltrationData()->getFilterData($filter->getName()) ?? new FilterData();

Expand Down

0 comments on commit 26ad423

Please sign in to comment.