From 6f625b7ad8a83ac4eae17d7dd24e1e75dbd8c1c7 Mon Sep 17 00:00:00 2001 From: wjh Date: Fri, 26 Apr 2024 20:19:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E7=BA=A7=E8=81=94?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=9C=A8=E7=BD=AE=E7=A9=BA=E5=90=8E=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=8F=8A=E6=97=B6=E6=B8=85=E9=99=A4=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E5=86=85=E5=AE=B9=20close=20#831=20(#866)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/866 Co-authored-by: wjh Co-committed-by: wjh --- .../antd/association-field/InternalCascader.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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?) {