diff --git a/src/fields/BaseRelationField.php b/src/fields/BaseRelationField.php index ae1d3c6c07f..b9c5a80c742 100644 --- a/src/fields/BaseRelationField.php +++ b/src/fields/BaseRelationField.php @@ -702,10 +702,8 @@ public function normalizeValue(mixed $value, ?ElementInterface $element): mixed if ( $this->sortable && !$this->maintainHierarchy && - ( - !$query->orderBy || - (count($query->orderBy) === 1) && ($query->orderBy[0] ?? null) instanceof OrderByPlaceholderExpression - ) + count($query->orderBy ?? []) === 1 && + ($query->orderBy[0] ?? null) instanceof OrderByPlaceholderExpression ) { $q->orderBy(["$relationsAlias.sortOrder" => SORT_ASC]); }