DateRangeWidget not respecting 'Empty facet behavior' facet option

Created on 2 August 2024, 8 months ago

Problem/Motivation

Perhaps by design or just never implemented, but the 'Empty facet behavior' option, as provided by the facets module, does not have any effect on the widget.

The this settings has 2 options, 'Do not display facet' and 'Display text'.

  • While 'Display text' feels weird to me in relation to what this widget does. Offering additional option on the widget settings to overrule the 'Display text' behavior, to keep show the widget for example, could be a solution.
  • The 'Do not display facet' options is one that should work, from my point of view

However, hiding the widget when there are no results (for the widget) makes it impossible to undo the filtering (cfr 🐛 Date facet disappears when no results Active ), therefor I recommend to combine this with 🐛 Date range facet values don't appear in Facets Summary Needs review .

Steps to reproduce

When filtering on a date (range) that does not produce any results, the widget is still shown, regardless the selection in 'Empty facet behavior'.

Proposed resolution

Removing items from the results that do not match the date range search condition post query, should result in an empty result set for the widget when appropriate.
This in turn will cause \Drupal\facets\FacetManager\DefaultFacetManager::build() to handle the facet empty behaviour.

Remaining tasks

Decide if we want to offer opt-out and/or override for the 'Display text' option.

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇧🇪Belgium andreasderijcke Antwerpen / Gent

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