From 7c579742dd92ea515963de81837c7556cf82c87a Mon Sep 17 00:00:00 2001 From: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com> Date: Mon, 20 Oct 2025 15:09:48 +0200 Subject: [PATCH 1/2] fix: add validations to rangeDate filter Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com> --- .../app/components/FilterPanel/DateRangeFilter.tsx | 13 +++++++++---- .../components/FilterToolbar/DateRangeFilter.tsx | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/client/src/app/components/FilterPanel/DateRangeFilter.tsx b/client/src/app/components/FilterPanel/DateRangeFilter.tsx index 68ccfb31..ad051a30 100644 --- a/client/src/app/components/FilterPanel/DateRangeFilter.tsx +++ b/client/src/app/components/FilterPanel/DateRangeFilter.tsx @@ -4,6 +4,7 @@ import { DatePicker, Form, FormGroup, + isValidDate, isValidDate as isValidJSDate, } from "@patternfly/react-core"; @@ -72,6 +73,11 @@ export const DateRangeFilter = ({ } }; + const toValidator = (date: Date) => + from && isValidDate(from) && date >= from + ? "" + : 'The "to" date must be after the "from" date'; + return (
@@ -82,8 +88,7 @@ export const DateRangeFilter = ({ onChange={onFromDateChange} aria-label="Interval start" placeholder="MM/DD/YYYY" - // disable error text (no space in toolbar scenario) - invalidFormatText={""} + invalidFormatText={"Invalid date"} // default value ("parent") creates collision with sticky table header appendTo={document.body} isDisabled={isDisabled} @@ -96,9 +101,9 @@ export const DateRangeFilter = ({ isDisabled={isDisabled || !isValidJSDate(from)} dateFormat={americanDateFormat} dateParse={parseAmericanDate} - // disable error text (no space in toolbar scenario) - invalidFormatText={""} + invalidFormatText={"Invalid date"} rangeStart={from} + validators={[toValidator]} aria-label="Interval end" placeholder="MM/DD/YYYY" appendTo={document.body} diff --git a/client/src/app/components/FilterToolbar/DateRangeFilter.tsx b/client/src/app/components/FilterToolbar/DateRangeFilter.tsx index a27a8bdc..26d5fd01 100644 --- a/client/src/app/components/FilterToolbar/DateRangeFilter.tsx +++ b/client/src/app/components/FilterToolbar/DateRangeFilter.tsx @@ -7,6 +7,7 @@ import { type ToolbarLabel, type ToolbarLabelGroup, Tooltip, + isValidDate, isValidDate as isValidJSDate, } from "@patternfly/react-core"; @@ -115,6 +116,11 @@ export const DateRangeFilter = ({ } }; + const toValidator = (date: Date) => + from && isValidDate(from) && date >= from + ? "" + : 'The "to" date must be after the "from" date'; + return ( ({ onChange={onFromDateChange} aria-label="Interval start" placeholder="MM/DD/YYYY" - // disable error text (no space in toolbar scenario) - invalidFormatText={""} + invalidFormatText={"Invalid date"} // default value ("parent") creates collision with sticky table header appendTo={document.body} isDisabled={isDisabled} @@ -144,9 +149,9 @@ export const DateRangeFilter = ({ isDisabled={isDisabled || !isValidJSDate(from)} dateFormat={americanDateFormat} dateParse={parseAmericanDate} - // disable error text (no space in toolbar scenario) - invalidFormatText={""} + invalidFormatText={"Invalid date"} rangeStart={from} + validators={[toValidator]} aria-label="Interval end" placeholder="MM/DD/YYYY" appendTo={document.body} From 2f85297878b67c96427fa356ef6652ed1265b2eb Mon Sep 17 00:00:00 2001 From: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com> Date: Mon, 20 Oct 2025 15:16:27 +0200 Subject: [PATCH 2/2] fix: format Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com> --- .../src/app/components/FilterPanel/DateRangeFilter.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/app/components/FilterPanel/DateRangeFilter.tsx b/client/src/app/components/FilterPanel/DateRangeFilter.tsx index ad051a30..62b2f495 100644 --- a/client/src/app/components/FilterPanel/DateRangeFilter.tsx +++ b/client/src/app/components/FilterPanel/DateRangeFilter.tsx @@ -73,11 +73,11 @@ export const DateRangeFilter = ({ } }; - const toValidator = (date: Date) => - from && isValidDate(from) && date >= from - ? "" - : 'The "to" date must be after the "from" date'; - + const toValidator = (date: Date) => + from && isValidDate(from) && date >= from + ? "" + : 'The "to" date must be after the "from" date'; + return (