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
- Create a Search API based View.
- Add multiple exposed
facets_filterfilters to the same display. - Configure them as a drill-down sequence, for example Manufacturer, Product, and File type.
- Select a parent filter value.
- Select a child filter value.
- 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
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
Comment #4
danielehrenhoferCreated merge request !378 against 3.0.x.
Comment #5
danielehrenhoferComment #6
danielehrenhoferComment #10
mkalkbrennerComment #12
danielehrenhofer