Skip to content

Commit 15f7dc8

Browse files
committed
Add usesSelect to resolve column select breaking change
1 parent fa3f5bd commit 15f7dc8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Traits/WithColumnSelect.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,28 @@ trait WithColumnSelect
1212
public bool $columnSelect = false;
1313
public array $columnSelectEnabled = [];
1414

15+
public bool $usesSelect = false;
16+
1517
public function mountWithColumnSelect(): void
1618
{
1719
// If the column select is off, make sure to clear the session
1820
if (! $this->columnSelect && session()->has($this->getColumnSelectSessionKey())) {
1921
session()->forget($this->getColumnSelectSessionKey());
2022
}
2123

24+
$selected = collect($this->columns())
25+
->filter(fn ($column) => $column->isSelected())->count();
26+
27+
if ($selected > 0) $this->usesSelect = true;
28+
2229
// Get a list of visible default columns that are not excluded
2330
$columns = collect($this->columns())
24-
->filter(fn ($column) => $column->isVisible() && $column->isSelectable() && $column->isSelected())
31+
->filter(function ($column) {
32+
if ($this->usesSelect) {
33+
return $column->isVisible() && $column->isSelectable() && $column->isSelected();
34+
}
35+
return $column->isVisible() && $column->isSelectable();
36+
})
2537
->map(fn ($column) => $column->column())
2638
->values()
2739
->toArray();

0 commit comments

Comments
 (0)