From 6808620a3da22db1dcfba2e720f325041b268b75 Mon Sep 17 00:00:00 2001 From: Zeke Zhang <958414905@qq.com> Date: Mon, 28 Apr 2025 14:12:28 +0800 Subject: [PATCH] fix: refreshing the page after switching operators causes an error (#6781) * fix: clear default value when switching operators to prevent filtering API errors * fix: update EditOperator to set default value to null and assign componentProps to x-component-props * fix: set field value and initialValue to null in EditOperator to ensure proper state management --- .../antd/form-item/SchemaSettingOptions.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/core/client/src/schema-component/antd/form-item/SchemaSettingOptions.tsx b/packages/core/client/src/schema-component/antd/form-item/SchemaSettingOptions.tsx index 4193c7951d..5d2693c14b 100644 --- a/packages/core/client/src/schema-component/antd/form-item/SchemaSettingOptions.tsx +++ b/packages/core/client/src/schema-component/antd/form-item/SchemaSettingOptions.tsx @@ -535,11 +535,19 @@ export const EditOperator = () => { } field.componentProps = componentProps; + fieldSchema['x-component-props'] = componentProps; + fieldSchema.default = null; + field.value = null; + field.initialValue = null; + dn.emit('patch', { schema: { ['x-uid']: fieldSchema['x-uid'], ['x-component-props']: componentProps, ['x-filter-operator']: v, + // Clear default value when switching operators. Some operators require the default value to be an array, + // while others don't. Without clearing it, the filtering API would throw an error + default: null, }, }); dn.refresh();