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:
		
							parent
							
								
									a52816cc86
								
							
						
					
					
						commit
						3c4000fdad
					
				@ -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) => {
 | 
				
			||||||
 | 
				
			|||||||
@ -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);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user