From 09985ed8bce5451da01fc7e12326c931abb1ffb4 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Mon, 4 Mar 2024 17:28:33 +0800 Subject: [PATCH] fix: field hidden with linkage rule should clear value (#3576) --- .../core/client/src/schema-component/antd/form-v2/Form.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core/client/src/schema-component/antd/form-v2/Form.tsx b/packages/core/client/src/schema-component/antd/form-v2/Form.tsx index 3a423398e..30bff23d2 100644 --- a/packages/core/client/src/schema-component/antd/form-v2/Form.tsx +++ b/packages/core/client/src/schema-component/antd/form-v2/Form.tsx @@ -268,6 +268,10 @@ function getSubscriber( } } else { field[fieldName] = lastState?.value; + //字段隐藏时清空数据 + if (fieldName === 'display' && lastState?.value === 'none') { + field.value = null; + } } // 在这里清空 field.stateOfLinkageRules,就可以保证:当条件再次改变时,如果该字段没有和任何条件匹配,则需要把对应的值恢复到初始值;