Problem/Motivation

Hierarchical facets exposed through facets_exposed_filters can keep both a parent and a child value active at the same time.

Example submitted exposed filter values:

date[2025]=2025&date[2025-10]=2025-10

When keep_hierarchy_parents_active is disabled, this should behave like selecting only the child value. Instead, both values are passed to the facet query, which can broaden the result set and show too many results.

The classic Facets QueryString URL processor already removes parent/child trail values when building facet links if keep_hierarchy_parents_active is disabled. Exposed facet filters should apply the same normalization to submitted exposed filter values before executing the query.

Steps to reproduce

  1. Create a Search API View with a hierarchical exposed facet filter using facets_exposed_filters.
  2. Use a hierarchy such as date_items.
  3. Leave keep_hierarchy_parents_active disabled.
  4. Submit the exposed form with both a parent and child value active, for example date[2025]=2025 and date[2025-10]=2025-10.
  5. Check the result set and active exposed filter state.

Proposed resolution

Normalize active exposed facet values for hierarchical facets before query execution and exposed form rebuild.

If keep_hierarchy_parents_active is disabled, remove active parent values when one of their child values is also active. Keep unrelated active values from other hierarchy branches unchanged.

This fix only normalizes submitted exposed filter values before query execution. It does not restore the parent trail when an active child value is unchecked, because exposed filters do not have the same link-building state as classic facet links.

Issue fork facets-3592378

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

danielehrenhofer created an issue. See original summary.

danielehrenhofer’s picture

Status: Active » Needs review
danielehrenhofer’s picture

Status: Needs review » Needs work
danielehrenhofer’s picture

Status: Needs work » Needs review

mkalkbrenner’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

danielehrenhofer’s picture

Assigned: danielehrenhofer » Unassigned