From aa59e0131f73c668cfd290e54b7dfdaa496a9048 Mon Sep 17 00:00:00 2001 From: Katherine Date: Mon, 7 Apr 2025 16:02:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20rule=20with=20'any'=20condition=20does?= =?UTF-8?q?=20not=20take=20effect=20when=20condition=20li=E2=80=A6=20(#662?= =?UTF-8?q?8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: rule with 'any' condition does not take effect when condition list is empty * fix: bug --- .../core/client/src/schema-component/common/utils/uitls.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core/client/src/schema-component/common/utils/uitls.tsx b/packages/core/client/src/schema-component/common/utils/uitls.tsx index 198f98cfa5..e2359e5eef 100644 --- a/packages/core/client/src/schema-component/common/utils/uitls.tsx +++ b/packages/core/client/src/schema-component/common/utils/uitls.tsx @@ -96,7 +96,6 @@ export const conditionAnalyses = async ( ) => { const type = Object.keys(ruleGroup)[0] || '$and'; const conditions = ruleGroup[type]; - let results = conditions.map(async (condition) => { if ('$and' in condition || '$or' in condition) { return await conditionAnalyses({ ruleGroup: condition, variables, localVariables }, jsonLogic); @@ -147,7 +146,10 @@ export const conditionAnalyses = async ( if (type === '$and') { return every(results, (v) => v); } else { - return some(results, (v) => v); + if (results.length) { + return some(results, (v) => v); + } + return true; } };