Skip to content

SRVKP-13054: Fix close option for the date range filter#1191

Open
adityavshinde wants to merge 1 commit into
openshift-pipelines:masterfrom
adityavshinde:fix/SRVKP-13054
Open

SRVKP-13054: Fix close option for the date range filter#1191
adityavshinde wants to merge 1 commit into
openshift-pipelines:masterfrom
adityavshinde:fix/SRVKP-13054

Conversation

@adityavshinde

Copy link
Copy Markdown
Contributor

Type of Change

  • Bug fix
  • New feature
  • Refactoring
  • Migration
  • CVE Fix

Summary

The date range filter chip's close (X) button was not clearing the filter. When clicking X, deleteChip removes the value from the array producing [], then calls onFilterChange('timeRange', []). Since empty arrays are truthy in JavaScript, the old code value ? parseDurationForDateRangeFiltering(value as string) : NO_DATE_RANGE_FILTER would enter the truthy branch and try to parse [] as a string instead of clearing the filter.

@openshift-ci-robot

openshift-ci-robot commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

@adityavshinde: This pull request references SRVKP-13054 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Type of Change

  • Bug fix
  • New feature
  • Refactoring
  • Migration
  • CVE Fix

Summary

The date range filter chip's close (X) button was not clearing the filter. When clicking X, deleteChip removes the value from the array producing [], then calls onFilterChange('timeRange', []). Since empty arrays are truthy in JavaScript, the old code value ? parseDurationForDateRangeFiltering(value as string) : NO_DATE_RANGE_FILTER would enter the truthy branch and try to parse [] as a string instead of clearing the filter.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci

openshift-ci Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: adityavshinde
Once this PR has been reviewed and has the lgtm label, please assign arvindk-softwaredev for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@qodo-code-review

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Warning

/review is deprecated. Use /agentic_review instead (removal date not yet scheduled).

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

@adityavshinde
adityavshinde requested review from anwesha-palit-redhat and removed request for vdemeester July 23, 2026 06:31
@anwesha-palit-redhat
anwesha-palit-redhat requested review from ankrsinha and removed request for anwesha-palit-redhat July 23, 2026 09:13
Comment thread src/components/hooks/useDataViewFilter.ts Outdated
Signed-off-by: Aditya Shinde <adishind@redhat.com>
@ankrsinha

Copy link
Copy Markdown
Contributor

The fix looks good to me. Attaching the verification recording

/lgtm

Screencast.From.2026-07-23.15-26-13.mp4

@openshift-ci openshift-ci Bot added the lgtm Looks Good to Me Label label Jul 23, 2026
const onFilterChange = useCallback(
(key: string, value: string | string[]) => {
if (key === 'timeRange') {
const selected = Array.isArray(value) ? value[0] : value;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Are we expecting value to ever be a standalone string here, or is it always an array (or empty/null)?

If it's always an array when present, returning null as the fallback might be cleaner and avoid returning an unexpected non-array value ? wdyt ?

const selected = Array.isArray(value) ? value[0] : null;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there are two cases:

  1. When a time range is selected ( 1w for example ) which is string
  2. When user clicks the close icon
    for the second one we are getting empty array, so both the situations are being used here.

@anwesha-palit-redhat

Copy link
Copy Markdown
Contributor

verified and changes are working, left a nit

PipelineRun

verification-1.mov

TaskRun

verification1.mov
verification2.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants