🐛 | Better Exposed Filters | Collapsible "details" element remain expanded after search. need to be closed by default after search.
🇬🇧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;
}
}
}
}
🇬🇧United Kingdom masher
+1