diff --git a/packages/core/client/src/schema-component/antd/association-field/InternalCascader.tsx b/packages/core/client/src/schema-component/antd/association-field/InternalCascader.tsx index 3dbf9391a..be34327d3 100644 --- a/packages/core/client/src/schema-component/antd/association-field/InternalCascader.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/InternalCascader.tsx @@ -17,7 +17,7 @@ import { useTranslation } from 'react-i18next'; import { CustomCascader, SchemaComponent } from '../..'; import { css, useAPIClient } from '../../..'; import { mergeFilter } from '../../../filter-provider/utils'; -import { useAssociationFieldContext } from './hooks'; +import useServiceOptions, { useAssociationFieldContext } from './hooks'; const SchemaField = createSchemaField({ components: { @@ -55,7 +55,6 @@ const Cascade = connect((props) => { }); setSelectedOptions(defaultData); } - onDropdownVisibleChange('true'); }, [fieldSchema['x-component-props'].value]); const handleGetOptions = async () => { const response = await resource.list({ @@ -97,6 +96,8 @@ const Cascade = connect((props) => { } }); onChange?.(options); + } else { + onChange?.([]); } }; const cascadeOption = (option) => { @@ -164,6 +165,7 @@ export const InternalCascader = observer( const { t } = useTranslation(); const field: any = useField(); const fieldSchema = useFieldSchema(); + const service = useServiceOptions(props); useEffect(() => { const id = uid(); selectForm.addEffects(id, () => { @@ -253,6 +255,7 @@ export const InternalCascader = observer( 'x-component': AssociationCascadeSelect, 'x-component-props': { ...props, + service, style: { width: '100%' }, }, 'x-read-pretty': false, @@ -264,7 +267,7 @@ export const InternalCascader = observer( ); }, - { displayName: 'InternalCascade' }, + { displayName: 'InternalCascader' }, ); function extractLastNonNullValueObjects(data, flag?) {