Empty facet defaults to range of 1970 to +100 years

Created on 8 July 2024, 5 months ago

Problem/Motivation

I am using the date picker widget.

If I delete the value from both inputs and submit the form again,
the min date defaults to timestamp 0 ( 1970 ).

My expectation would be to not apply the facet at all.

It would be ok if I had results from 1970 forwards, but I actually have results from earlier than that.

Steps to reproduce

Let's assume that my earliest result is from 1900.

  1. Add a date facet date range to your search ( choose the date picker widget ).
  2. Start a new search, input a min and max date.
  3. Delete the values from both inputs and submit the form again.
    ( You will read &f[0]=date_facets:(min:,max:) in the query string. )

Expected behaviour: Returns results from 1900 and forwards.
Actual behaviour: Returns results from 1970 and forwards.

Proposed resolution

DateRangeProcessor::preQuery() defaults to a range of [0, +100 years].
I think we should add a conditional statement to return [] if both are empty.

Alternatively we could update the Drupal.behaviors.facetsDateRange java-script behaviour to not include the facet in the URL in case both inputs are empty.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇧🇷Brazil adinancenci

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

Comments & Activities

Production build 0.71.5 2024