From 3c4000fdadddc633427911fff53844c8b8c4b675 Mon Sep 17 00:00:00 2001 From: Zeke Zhang <958414905@qq.com> Date: Mon, 29 Jan 2024 19:00:25 +0800 Subject: [PATCH] fix(CascadeSelect): should change value when deleting value (#3440) * fix(CascadeSelect): should change value when deleting value * fix: cascadeSelect should support clear option --------- Co-authored-by: katherinehhh --- .../schema-component/antd/association-field/Editable.tsx | 6 +++--- .../antd/association-field/InternalCascadeSelect.tsx | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/association-field/Editable.tsx b/packages/core/client/src/schema-component/antd/association-field/Editable.tsx index bf2466e5c..9a1edc57d 100644 --- a/packages/core/client/src/schema-component/antd/association-field/Editable.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/Editable.tsx @@ -3,17 +3,17 @@ import { observer, useField, useForm } from '@formily/react'; import React from 'react'; import { SchemaComponentOptions } from '../../'; import { useAssociationCreateActionProps as useCAP } from '../../../block-provider/hooks'; +import { useCollection } from '../../../collection-manager'; import { AssociationFieldProvider } from './AssociationFieldProvider'; import { AssociationSelect } from './AssociationSelect'; import { InternalFileManager } from './FileManager'; +import { InternalCascadeSelect } from './InternalCascadeSelect'; import { InternalNester } from './InternalNester'; import { InternalPicker } from './InternalPicker'; -import { InternalSubTable } from './InternalSubTable'; import { InternaPopoverNester } from './InternalPopoverNester'; -import { InternalCascadeSelect } from './InternalCascadeSelect'; +import { InternalSubTable } from './InternalSubTable'; import { CreateRecordAction } from './components/CreateRecordAction'; import { useAssociationFieldContext } from './hooks'; -import { useCollection } from '../../../collection-manager'; const EditableAssociationField = observer( (props: any) => { diff --git a/packages/core/client/src/schema-component/antd/association-field/InternalCascadeSelect.tsx b/packages/core/client/src/schema-component/antd/association-field/InternalCascadeSelect.tsx index fefa431ac..b31377f1f 100644 --- a/packages/core/client/src/schema-component/antd/association-field/InternalCascadeSelect.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/InternalCascadeSelect.tsx @@ -130,8 +130,8 @@ const CascadeSelect = connect((props) => { const data = await handleGetOptions({ parentId: option?.id }); const options = [...selectedOptions]; options.splice(index + 1); - if (value) { - options[index] = { ...options[index], value: option }; + options[index] = { ...options[index], value: option }; + if (option?.id) { options[index + 1] = { key: option?.id, children: data?.length > 0 ? data : null }; } setSelectedOptions(options);