"hide filter, if no options" option not working

Created on 15 July 2025, 5 days ago

Problem/Motivation

We have a filter on taxonomy terms in our overview with the option "hide filter, if no options" enabled to hide if there are no results for the select. What we have noticed is that the filter will still always show up even though there are no options for the select.

Steps to reproduce

Add view with a filter which is able to select multiple values and enable the "hide filter, if no options" option.

Proposed resolution

What we noticed was that we never get into the if statement where the field is disabled. There is an if check with an else if the view results are empty, if that is the case set the access of the filter to false, but to get to the other if check:

if (
              !empty($settings['options_hide_when_empty'])
              && (
                  (count($element['#options']) == 1 && isset($element['#options']['All']))
                  || empty($element['#options'])
              )
            ) {
              $element['#access'] = FALSE;
            }

You need to get through the options empty check, which we dont have because we dont have options:

          if (!empty($element['#options'])) {
🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇳🇱Netherlands pdewringer

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

Comments & Activities

  • Issue created by @pdewringer
  • 🇳🇱Netherlands pdewringer

    What we have done currently is move that if statement to under the if where gets checked if the element has options

  • @pdewringer opened merge request.
Production build 0.71.5 2024