Hi, I'm using better_exposed_filters with secondary options, but there is a very annoying usability issue: after the user submits, the secondary options field always collapses.

I would like to see that after a submit, the secondary options stays open. Can this be fixed?

Files: 
CommentFileSizeAuthor
#10 bef-1983960-10.patch1.17 KBtim.plunkett
Test request sent.
[ View ]

Comments

same request for me

Ran into this problem too.
The "collapse" feature is implemented using the core form API, as supposed to.
Drawback is that there is no module-specific javascript file to patch for this.

If this is to be addressed within the module code, it should be in the "exposed_form_alter" function in "better_exposed_filters_exposed_form_plugin.inc".
$secondary['#collapsed'] is always set to TRUE. Here could be checked if there is user input in any of its containing fields.

To bypass patching you could implement this as a form_alter, checking user input to override #collapsed.
Simple example for one select filter (untested):

<?php
function mymodule_form_alter(&$form, &$form_state, $form_id){
  if(
$form_id == 'views_exposed_form' && isset($form['secondary'])) {
    if(isset(
$form['secondary']['myfilter']['#default_value']) && $form['secondary']['myfilter']['#default_value'] != 'All') {
     
// Do not collapse fieldset when a value is set
     
$form['secondary']['#collapsed'] = FALSE;
    }
  }
}
?>

Category:bug» feature

BEF should be checking all the items within the secondary menu to see if any have options selected and keep the fieldset open if there are.

Marking this as a feature request -- as always, patches are welcome!

sorry for my stupid questions:
- where should I put the code #2?
- mymodule_form_alter: sould I replace "mymodule" with anything else?
- myfilter: sould I replace "myfilter" with anything else?

Following code seems to work on my installation. Not providing a patch, since I haven't tested this thorougly (and I'm not sure if there are use cases where the $_GET key is different from the filter name).

<?php
/**
* Implements hook_form_views_exposed_form_alter().
*/
function mymodule_form_views_exposed_form_alter(&$form, $form_state) {
    if (isset(
$form['secondary'])) {
      foreach (
element_children($form['secondary']) as $key) {
        if (isset(
$_GET[$key]) && ($_GET[$key] !== '' && $_GET[$key] !== 'All')) {
         
$form['secondary']['#collapsed'] = FALSE;
          break;
        }
      }
    }
}
?>

it works perfectly, thanks.

#5 is a working workaround! Can anyone confirm whether there would be a problem in basing a patch off this approach?

Please be sure to include AJAX-based views in addition to filters that have a default option other than "all" set. (For the second, select an option in the configure filter dialog so that option appears as the default value when you navigate to the page with no querystring params).

And report back your results! Thanks.

#5 works for me.
Definitely seconding this as a feature request. More specifically, a set of options to select collapse behavior for secondary filters.

Issue summary:View changes
Status:Active» Needs review
StatusFileSize
new1.17 KB
Test request sent.
[ View ]

This is technically a feature request because it never worked and never claimed to, but from a UX perspective this is a major bug.

@tim.plunkett: Thank you for the patch. I've committed it -- you're right, this has been a major UX bug.

I would love to see the secondary options fieldset collapse when the selected options are returned to their defaults, though I suppose that's what the Reset button is for. :)

Status:Needs review» Fixed

it still collapses in cases when users change their filter identifier in Views UI. I've created a separate issue for that.
#2189321: Secondary options closed after submit if filter identifier is not left default.

Status:Fixed» Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.