From 6fa2c8c79201b9ea34321277ab085fa0ba988d77 Mon Sep 17 00:00:00 2001 From: Harshvardhan Sharma <91624754+vardhan0604@users.noreply.github.com> Date: Wed, 7 Aug 2024 18:34:06 +0530 Subject: [PATCH] fix: Filter string is erased when changing filter condition (#2586) --- src/components/Filter/Filter.react.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Filter/Filter.react.js b/src/components/Filter/Filter.react.js index f9490c4958..29397f4213 100644 --- a/src/components/Filter/Filter.react.js +++ b/src/components/Filter/Filter.react.js @@ -51,7 +51,7 @@ function changeField(schema, currentClassName, filters, index, newField) { return filters.set(index, newFilter); } -function changeConstraint(schema, currentClassName, filters, index, newConstraint) { +function changeConstraint(schema, currentClassName, filters, index, newConstraint, prevCompareTo) { const field = filters.get(index).get('field'); let compareType = schema[currentClassName][field].type; if (Object.prototype.hasOwnProperty.call(Filters.Constraints[newConstraint], 'field')) { @@ -61,7 +61,7 @@ function changeConstraint(schema, currentClassName, filters, index, newConstrain class: currentClassName, field: field, constraint: newConstraint, - compareTo: Filters.DefaultComparisons[compareType], + compareTo: (compareType && prevCompareTo) ? prevCompareTo : Filters.DefaultComparisons[compareType], }); return filters.set(index, newFilter); }