From b137b3346d49d2e1ce09028f61211b5cdf2bb3d4 Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Fri, 16 Feb 2024 10:09:42 -0600 Subject: [PATCH] CE-798 - A fix for last change here, where if criteria came from outside this component, then changing operator wouldn't take - another check of isOpen in some of the reset code. --- src/qqq/components/query/QuickFilter.tsx | 30 +++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/qqq/components/query/QuickFilter.tsx b/src/qqq/components/query/QuickFilter.tsx index 7dbbdef..5df73b2 100644 --- a/src/qqq/components/query/QuickFilter.tsx +++ b/src/qqq/components/query/QuickFilter.tsx @@ -190,14 +190,24 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData ////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (criteriaParamIsCriteria(criteriaParam) && JSON.stringify(criteriaParam) !== JSON.stringify(criteria)) { - //////////////////////////////////////////////////////////////////////////////////////////////////////// - // copy the criteriaParam to a new object in here - so changes won't apply until user closes the menu // - //////////////////////////////////////////////////////////////////////////////////////////////////////// - const newCriteria = Object.assign({}, criteriaParam) as QFilterCriteriaWithId; - setCriteria(newCriteria); - const operatorOption = operatorOptions.filter(o => o.value == newCriteria.operator)[0]; - setOperatorSelectedValue(operatorOption); - setOperatorInputValue(operatorOption.label); + if(isOpen) + { + //////////////////////////////////////////////////////////////////////////////// + // this was firing too-often for case where: there was a criteria originally // + //////////////////////////////////////////////////////////////////////////////// + console.log("Not handling outside change (A), because dropdown is-open"); + } + else + { + //////////////////////////////////////////////////////////////////////////////////////////////////////// + // copy the criteriaParam to a new object in here - so changes won't apply until user closes the menu // + //////////////////////////////////////////////////////////////////////////////////////////////////////// + const newCriteria = Object.assign({}, criteriaParam) as QFilterCriteriaWithId; + setCriteria(newCriteria); + const operatorOption = operatorOptions.filter(o => o.value == newCriteria.operator)[0]; + setOperatorSelectedValue(operatorOption); + setOperatorInputValue(operatorOption.label); + } } /******************************************************************************* @@ -218,6 +228,7 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData // this was firing too-often for case where: there was no criteria originally, // // so, by adding this is-open check, we eliminated those. // ////////////////////////////////////////////////////////////////////////////////// + console.log("Not handling outside change (B), because dropdown is-open"); return (false); } @@ -312,6 +323,9 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData setOperatorSelectedValue(null); setOperatorInputValue(""); } + + setCriteria(criteria); + forceUpdate(); }; /*******************************************************************************