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 e8597cd47..96b8bb1b8 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 @@ -22,7 +22,7 @@ const SchemaField = createSchemaField({ }); const CascadeSelect = connect((props) => { - const { data, mapOptions, onChange } = props; + const { data, mapOptions, onChange, value } = props; const [selectedOptions, setSelectedOptions] = useState<{ key: string; children: any; value?: any }[]>([ { key: undefined, children: [], value: null }, ]); @@ -47,10 +47,10 @@ const CascadeSelect = connect((props) => { }, [targetField]); const field: any = useField(); useEffect(() => { - if (props.value) { - const values = Array.isArray(props.value) - ? extractLastNonNullValueObjects(props.value?.filter((v) => v.value), true) - : transformNestedData(props.value); + if (value) { + const values = Array.isArray(value) + ? extractLastNonNullValueObjects(value?.filter((v) => v.value), true) + : transformNestedData(value); const options = values?.map?.((v) => { return { key: v.parentId, @@ -302,24 +302,26 @@ export const InternalCascadeSelect = observer( }, }; return ( - - {collectionField.interface === 'm2o' ? ( - - ) : ( - - )} - + props.value !== null && ( + + {collectionField.interface === 'm2o' ? ( + + ) : ( + + )} + + ) ); }, { displayName: 'InternalCascadeSelect' },