fix(cascadeSelect): cassadeSelect does not dislay data in edit form (#3649)
This commit is contained in:
parent
263ee28c72
commit
16581a547c
@ -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,6 +302,7 @@ export const InternalCascadeSelect = observer(
|
||||
},
|
||||
};
|
||||
return (
|
||||
props.value !== null && (
|
||||
<FormProvider form={selectForm}>
|
||||
{collectionField.interface === 'm2o' ? (
|
||||
<SchemaComponent
|
||||
@ -320,6 +321,7 @@ export const InternalCascadeSelect = observer(
|
||||
<SchemaField schema={schema} />
|
||||
)}
|
||||
</FormProvider>
|
||||
)
|
||||
);
|
||||
},
|
||||
{ displayName: 'InternalCascadeSelect' },
|
||||
|
Loading…
Reference in New Issue
Block a user