Collapsible details element not hidden if "Hide filter, if no options" is selected.

Created on 7 August 2023, over 1 year ago

I'm not sure if this is a BEF issue or just a Drupal core issue or maybe even specific to my custom theme, but I have an exposed filter block setup to show in my left sidebar for a view that is doing a site search. The first exposed filter displays checkboxes to filter by content type and the second exposed filter are checkboxes to sort by a taxonomy called "Topic".

In my BEF settings for each exposed filter I have the following settings: "Show only used items", "Filter items based on filtered result set", "Hide filter, if no options", and "Make filter options collapsible". The search itself works as intended, but if the search results in there not being any content types to choose from or Topics to choose from, the collapsible detail element still shows, but it is empty. I would think that if there are no results which would provide any options to choose form the entire element would be hidden, or at least that is the behavior that I am looking for and what I thought the "Hide filter, if no options" setting would do. I would like to not show an empty details element, but hide the whole thing if empty. Is this a bug or is it working as intended? If this isn't a bug, is there a way to make this happen?

Here is what I get if I search for something with no results:

πŸ› Bug report
Status

Active

Version

6.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States socalerich

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

Comments & Activities

  • Issue created by @socalerich
  • Status changed to Postponed: needs info 7 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Could you provide steps for reproducing this?

  • Status changed to Closed: outdated 7 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    If still a problem in 6.0.x please reopen

  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

    This is still an issue, at least when used with the latest Facets 3.x

    1. Configure facets within Views as documented in https://project.pages.drupalcode.org/facets/exposed_filters/
    2. In Better Exposed Filters settings on the view, under Exposed Filter Settings, open Advanced filter options and enable Make filter options collapsible ("Puts the filter options in a collapsible details element.")
    3. Visit the view and filter by another facet so one set to be in a Details element has no results.
    4. Note that the facet label is still there as the summary for the details element, but nothing is inside.
    5. Change the Exposed Filter Settings option to not make filter options collapsible.
    6. Reload the view and see that now the facet label is gone, as expected.
  • Status changed to Active 24 days ago
  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Should be verified in 7.0.x first

  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

    Thanks, i realized that after posting and upgraded, and it is still the case on 7.0.2 at least.

  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

    Configurable Views Filter Block shows Better Exposed Filters facets-sourced Details elements (label, no options) even when not selected in the block if that is helpful for pointing me at where to try to fix this. Thanks!

  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

    Nothing like writing ones own Better Exposed Filter plugin - https://www.drupal.org/project/bef_links_filter β†’ - to get a better sense of how this all works. Implemented a workaround in πŸ› Prevent collapsible fieldset from showing when facet is empty Active but the fix here should be to put the wrapping of facet into a details element on line 254 of better_exposed_filters/src/Plugin/better_exposed_filters/filter/FilterWidgetBase.php in a if (!empty($form[$field_id])) { … } block, unless that does not work for all better_exposed_filter plugins?

Production build 0.71.5 2024