If you have two active filters and only the second one exposed the default sorting will be the one from the first filter not from the exposed one.
Example we have nodes with an optional field "field_1" we want to sort this alphabetically but have nodes with "field_1" first, this will have first sort: "field_1" DESC then the exposed filter "title" ASC. The result is wrongly having default sort title DESC.

Issue in Code:the issue is caused by line 235 in the "views_plugin_exposed_form.inc" file.

$first_sort = reset($this->view->sort);

this just gets the first sorting it finds thus generating the bug

Proposed fix:
insert after row 235:

foreach($this->view->sort as $k=>$sort){
              if($sort->options['exposed']){
                  $first_sort = $this->view->sort[$k];
                  break;
              }
}

this picks up the default order form the first exposed filter not from the first filter that is applied

Comments

jansan’s picture

I'm facing the same issue here. Any updates?