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 <katherine_15995@163.com>
This commit is contained in:
Zeke Zhang 2024-01-29 19:00:25 +08:00 committed by GitHub
parent a52816cc86
commit 3c4000fdad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -3,17 +3,17 @@ import { observer, useField, useForm } from '@formily/react';
import React from 'react'; import React from 'react';
import { SchemaComponentOptions } from '../../'; import { SchemaComponentOptions } from '../../';
import { useAssociationCreateActionProps as useCAP } from '../../../block-provider/hooks'; import { useAssociationCreateActionProps as useCAP } from '../../../block-provider/hooks';
import { useCollection } from '../../../collection-manager';
import { AssociationFieldProvider } from './AssociationFieldProvider'; import { AssociationFieldProvider } from './AssociationFieldProvider';
import { AssociationSelect } from './AssociationSelect'; import { AssociationSelect } from './AssociationSelect';
import { InternalFileManager } from './FileManager'; import { InternalFileManager } from './FileManager';
import { InternalCascadeSelect } from './InternalCascadeSelect';
import { InternalNester } from './InternalNester'; import { InternalNester } from './InternalNester';
import { InternalPicker } from './InternalPicker'; import { InternalPicker } from './InternalPicker';
import { InternalSubTable } from './InternalSubTable';
import { InternaPopoverNester } from './InternalPopoverNester'; import { InternaPopoverNester } from './InternalPopoverNester';
import { InternalCascadeSelect } from './InternalCascadeSelect'; import { InternalSubTable } from './InternalSubTable';
import { CreateRecordAction } from './components/CreateRecordAction'; import { CreateRecordAction } from './components/CreateRecordAction';
import { useAssociationFieldContext } from './hooks'; import { useAssociationFieldContext } from './hooks';
import { useCollection } from '../../../collection-manager';
const EditableAssociationField = observer( const EditableAssociationField = observer(
(props: any) => { (props: any) => {

View File

@ -130,8 +130,8 @@ const CascadeSelect = connect((props) => {
const data = await handleGetOptions({ parentId: option?.id }); const data = await handleGetOptions({ parentId: option?.id });
const options = [...selectedOptions]; const options = [...selectedOptions];
options.splice(index + 1); 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 }; options[index + 1] = { key: option?.id, children: data?.length > 0 ? data : null };
} }
setSelectedOptions(options); setSelectedOptions(options);