Hide filter, if no options" does not hide Apply button when no options are available

Created on 21 March 2024, 8 months ago
Updated 1 September 2024, 3 months ago

Problem/Motivation

When selecting "Hide filter, if no options" and there are no more filters to hide, the "Apply" button still shows up on the page.

Steps to reproduce

1. Add an exposed filter that uses Better Exposed Filters - tags is a good option here.
2. Make sure in the Settings for the exposed filter that the filter options are set to: "Show only used items", and "Hide filter, if no options" are set.
3. This bug shows even with only one filter added, but also shows if multiple filters are added as well.
4. Make sure that any content matching the view does not have any of the tags (or whatever taxonomy term you used) on the nodes.
5. Verify that the filter itself is hidden, but the "Apply" button still shows up.

Proposed resolution

I've got a MR/patch in the works that fixes this, but don't know if my fix is the best way to approach this so I would love a review and feedback on it.

Essentially, when the check is made in the existing code and the $element['#access'] = FALSE, some additional code will also check to see if all elements are "hidden" and if so, also set the form access to false.

Remaining tasks

Review forthcoming patch.

User interface changes

None.

API changes

None.

Data model changes

None - except the code in my patch does add an additional "temporary" key to each element in the exposedFormAlter that is used in checking if the element was hidden by selective better exposed filters.

πŸ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States codechefmarc

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024