From 1e7b4ba21e6736c7ca2e67acf5f2358ceaaf7243 Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Thu, 25 Sep 2025 15:31:06 +0530 Subject: [PATCH] Date field not cleared in Tenant filter after clicking Clear button --- src/components/Tenant/TenantFilterPanel.jsx | 2 +- src/components/common/DateRangePicker.jsx | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/Tenant/TenantFilterPanel.jsx b/src/components/Tenant/TenantFilterPanel.jsx index 06f8ae01..f51f5245 100644 --- a/src/components/Tenant/TenantFilterPanel.jsx +++ b/src/components/Tenant/TenantFilterPanel.jsx @@ -38,7 +38,7 @@ const TenantFilterPanel = ({ onApply }) => { ); - // ✅ Close popup when navigating to another component + // Close popup when navigating to another component const location = useLocation(); useEffect(() => { handleClosePanel(); diff --git a/src/components/common/DateRangePicker.jsx b/src/components/common/DateRangePicker.jsx index c349e25a..72aad155 100644 --- a/src/components/common/DateRangePicker.jsx +++ b/src/components/common/DateRangePicker.jsx @@ -148,10 +148,20 @@ export const DateRangePicker1 = ({ }, []); useEffect(() => { - if (defaultRange && resetSignal !== undefined) { + if (resetSignal !== undefined) { + if (defaultRange) { applyDefaultDates(); + } else { + setValue(startField, "", { shouldValidate: true }); + setValue(endField, "", { shouldValidate: true }); + + if (inputRef.current?._flatpickr) { + inputRef.current._flatpickr.clear(); + } } - }, [resetSignal, defaultRange]); + } +}, [resetSignal, defaultRange, setValue, startField, endField]); + const start = getValues(startField); const end = getValues(endField);