Exposed views date filter with offset not working as expected

Created on 2 July 2018, almost 6 years ago
Updated 30 January 2024, 5 months ago

Problem/Motivation

When using a date/time filed as exposed filter using the "offset from the current time" setting, the filter doesn't display as I expected.

The setting for the filter are:

This leads to the filter being displayed like:

As you can see the dates are output in the filter as the relative text string. This can lead to problems if using a date selector dialog.

Proposed resolution

The output I expected is:

This has the dates computed and entered in the input element.

<!-- h3 id="summary-remaining-tasks">Remaining tasks</h3 --><!--h3 id="summary-ui-changes">User interface changes</h3 --><!-- h3 id="summary-api-changes">API changes</h3 --><!-- h3 id="summary-data-model-changes">Data model changes</h3 -->
🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Views  →

Last updated 35 minutes ago

Created by

🇬🇧United Kingdom John Cook

Live updates comments and jobs are added and updated live.
  • views

    Involves, uses, or integrates with views. In Drupal 8 core, use the “VDC” tag instead.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇵🇱Poland Graber

    I finally created this https://www.drupal.org/project/date_filter → to address this issue and many other.
    Looks like issues like this have a very small chance to get enough attention and find their way into core so we have to handle that in contrib :(

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India junaidpv Kannur, Kerala

    Building on #44. Adding similar improvement as #38 but to the datetime filter in core datetime module.

  • 🇮🇳India junaidpv Kannur, Kerala

    Try fixing CCF.

  • Status changed to Needs work about 1 year ago
  • 🇺🇞United States smustgrave

    Was previously tagged for tests and issue summary update which still need to happen plese.

    Also please include interdiffs with patches.

  • 🇮🇳India junaidpv Kannur, Kerala

    Exactly same as #47, just re-rolled for 10.1.x

  • 🇫🇷France S3b0uN3t Nantes

    Hello,

    I tried to apply patch on comment #50, but it's thrown an error in datetime module :

    Warning: Undefined array key "type" in Drupal\datetime\Plugin\views\filter\Date->getOffset() (line 180 of core/modules/datetime/src/Plugin/views/filter/Date.php).

    Without this warning, the patch works perfectly on Drupal 10.2.2!

Production build 0.69.0 2024