Collapsible "details" element remain expanded after search. need to be closed by default after search.

Created on 15 February 2022, over 2 years ago
Updated 11 April 2024, 3 months ago

Problem/Motivation

Collapsible "details" element (with Exposed filter widget: Checkboxes/radio buttons) remain opened after search. need to be closed by default after search.

What is the best way to close one or more collapsible "details" elements (where input is selected for search) after search is performed?

Steps to reproduce

Create view
Add some (2-3) filter criteria
Select “Better Exposed Filters” in Page:Exposed Form
Enable Enable auto-submit
Enable Hide submit button
Exposed filter widget: Checkboxes/radio buttons
Enable Make filter options collapsible for some/all filter criteria
Save views
Access page and filter with filter criteria
Filter dropdown remain opened after search
If selected options from more than one Filter dropdown, all filter dropdown remained opened after search

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Closed: duplicate

Version

5.0

Component

Code

Created by

🇮🇳India narendragupta

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.

  • 🇬🇧United Kingdom masher

    Cheers for the solution!

    I had to amend the above code to work on Drupal 10:

    use Drupal\Core\Form\FormStateInterface;

    /**
    * Implements hook_form_alter().
    */
    function hook_form_alter(&$form, FormStateInterface $form_state, $form_id) {
    // BEF: close selects of exposed form when value is selected.
    if ($form_id == 'views_exposed_form') {
    foreach ($form as $k => $v) {
    if (str_contains($k, '_collapsible')) {
    $form[$k]['#open'] = FALSE;
    }
    }
    }
    }

  • Status changed to Closed: duplicate 3 months ago
  • 🇺🇸United States smustgrave

    Believe this should be covered by Allow not automatically opening collapsed filter Needs review

Production build 0.69.0 2024