diff --git a/modules/backend/behaviors/RelationController.php b/modules/backend/behaviors/RelationController.php index 542e4c7cf..2306b5ffb 100644 --- a/modules/backend/behaviors/RelationController.php +++ b/modules/backend/behaviors/RelationController.php @@ -706,8 +706,11 @@ class RelationController extends ControllerBehavior }); } else { - $widget->bindEvent('list.extendQueryBefore', function ($query) { + $widget->bindEvent('list.extendQueryBefore', function ($query) use ($widget) { $this->relationObject->addDefinedConstraintsToQuery($query); + if ($widget->getSortColumn()) { + $query->getQuery()->orders = []; + } }); } diff --git a/modules/backend/widgets/Lists.php b/modules/backend/widgets/Lists.php index 59fc31194..cd2b96723 100644 --- a/modules/backend/widgets/Lists.php +++ b/modules/backend/widgets/Lists.php @@ -532,7 +532,6 @@ class Lists extends WidgetBase $sortColumn = $column->relation . '_count'; } - $query->getQuery()->orders = []; $query->orderBy($sortColumn, $this->sortDirection); }