From 9f8d8ec9fabad06e0eb4b222611910e608729074 Mon Sep 17 00:00:00 2001 From: Ben Thomson Date: Mon, 2 Dec 2019 09:27:25 +0800 Subject: [PATCH] Force ordering when list widget column is sorted When ordering is applied externally, ie. by a relation config, the orderBy call in the List widget simply adds an additional field to the ordering clauses, which prevents lists in these scenarios from being re-ordered correctly. This changes the order clause so that the ordering is reset and only the specified column is ordered when the user sorts a column. Developers can continue to use the `extendQuery` event to do specialised custom ordering if required. Fixes #4439. --- modules/backend/widgets/Lists.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/backend/widgets/Lists.php b/modules/backend/widgets/Lists.php index 862e96d40..f1946d747 100644 --- a/modules/backend/widgets/Lists.php +++ b/modules/backend/widgets/Lists.php @@ -532,6 +532,7 @@ class Lists extends WidgetBase $sortColumn = $column->relation . '_count'; } + $query->getQuery()->orders = []; $query->orderBy($sortColumn, $this->sortDirection); }