Skip to content

Commit 68cb993

Browse files
Clear stale aggregate sort in updatedGroupBy lifecycle hook
Move the sort reset from rowsQuery to updatedGroupBy so it fires immediately when group by is cleared, preventing stale 'aggregate' or 'group_value' sort columns from reaching the base query. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 466f3a5 commit 68cb993

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/ReportBuilder.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ public function rowsQuery()
2525
$query = parent::rowsQuery();
2626

2727
if (! $this->hasGroupBy()) {
28-
if (in_array($this->sortBy, ['aggregate', 'group_value'], true)) {
29-
$this->sortBy = '';
30-
$query->reorder();
31-
}
32-
3328
return $query;
3429
}
3530

src/Support/Concerns/WithReportBuilder.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public function updatedSelectedColumns(): void
5656

5757
public function updatedGroupBy(): void
5858
{
59+
if (! $this->hasGroupBy() && in_array($this->sortBy, ['aggregate', 'group_value'], true)) {
60+
$this->sortBy = '';
61+
$this->sortDirection = 'asc';
62+
}
63+
5964
$this->resetPage();
6065
$this->displayColumns = $this->resolveColumns()->pluck('key')->toArray();
6166
}

0 commit comments

Comments
 (0)