Exposed filters wrong default sorting

Created on 12 November 2014, about 10 years ago
Updated 15 July 2024, 4 months ago

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

πŸ› Bug report
Status

Active

Version

3.0

Component

exposed filters

Created by

πŸ‡©πŸ‡ͺGermany tripleb

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024