Problem/Motivation

The facets_exposed_filters submodule allows Search API facets to be exposed as native Views exposed filters. These exposed facet filters can narrow each other based on the current result set, but there is currently no configuration option to declare that one exposed facet filter depends on another exposed filter being active.

Facets already has a dependent_processor, but that processor only supports regular facet entities. It does not apply to facets rendered as native Views exposed filters via facets_exposed_filters.

This makes drill-down interfaces harder to model. For example, a Product facet may need to depend on an active Manufacturer filter, and a File type facet may need to depend on an active Product filter. If child filter values remain submitted after a parent value changes or is removed, the exposed form can keep stale child values in the request.

Steps to reproduce

  1. Create a Search API based View.
  2. Add multiple exposed facets_filter filters to the same display.
  3. Configure them as a drill-down sequence, for example Manufacturer, Product, and File type.
  4. Select a parent filter value.
  5. Select a child filter value.
  6. Change or remove the parent filter value.

The child exposed filter can remain submitted even though its parent context is no longer active.

Proposed resolution

Add a depends_on_exposed_filter option to the facets_filter Views filter plugin.

The option should allow a site builder to select another exposed filter on the same View display as the parent dependency.

When the dependency is not satisfied, the dependent facet filter should not apply its exposed input and should not render its exposed form element. If a parent exposed filter changes or is removed from the exposed filter summary, dependent exposed filter values should be cleared before the exposed form is submitted.

Remaining tasks

  • Review implementation.
  • Add or update automated test coverage.

User interface changes

Adds a new setting to exposed facet filter configuration in Views: Depends on exposed filter.

API changes

Adds a new Views filter option: facet.depends_on_exposed_filter.

Issue fork facets-3592014

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 changed the visibility of the branch 3592014-exposed-filter-dependencies to hidden.

danielehrenhofer’s picture

Created merge request !378 against 3.0.x.

danielehrenhofer’s picture

Status: Active » Needs work
danielehrenhofer’s picture

Status: Needs work » Needs review

danielehrenhofer changed the visibility of the branch 3592014-exposed-filter-dependencies to active.

danielehrenhofer changed the visibility of the branch 3592014-exposed-filter-dependencies to hidden.

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

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.