SRVKP-13054: Fix close option for the date range filter#1191
SRVKP-13054: Fix close option for the date range filter#1191adityavshinde wants to merge 1 commit into
Conversation
|
@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. DetailsIn response to this:
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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: adityavshinde The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
PR Reviewer Guide 🔍Warning
Here are some key observations to aid the review process:
|
Signed-off-by: Aditya Shinde <adishind@redhat.com>
7b10b4f to
c660802
Compare
|
The fix looks good to me. Attaching the verification recording /lgtm Screencast.From.2026-07-23.15-26-13.mp4 |
| const onFilterChange = useCallback( | ||
| (key: string, value: string | string[]) => { | ||
| if (key === 'timeRange') { | ||
| const selected = Array.isArray(value) ? value[0] : value; |
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
So there are two cases:
- When a time range is selected ( 1w for example ) which is string
- When user clicks the close icon
for the second one we are getting empty array, so both the situations are being used here.
|
verified and changes are working, left a PipelineRunverification-1.movTaskRunverification1.movverification2.mov |
Type of Change
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 codevalue ? parseDurationForDateRangeFiltering(value as string) : NO_DATE_RANGE_FILTERwould enter the truthy branch and try to parse [] as a string instead of clearing the filter.