fix: fix error when clear RecordPicker

This commit is contained in:
Rairn 2023-04-25 16:45:03 +08:00
parent 0a8fd44816
commit bc8d81333b

View File

@ -184,12 +184,16 @@ export const InputRecordPicker: React.FC<any> = (props: IRecordPickerProps) => {
allowClear
onChange={(changed: any) => {
if (!changed) {
onChange([]);
setSelectedRows([]);
} else if (!changed?.length) {
onChange([]);
setSelectedRows([]);
const value = multiple ? [] : null;
onChange(value);
setSelectedRows(value);
} else if (Array.isArray(changed)) {
if (!changed.length) {
onChange([]);
setSelectedRows([]);
return;
}
const values = options?.filter((option) => changed.includes(option[fieldNames.value]));
onChange(values);
setSelectedRows(values);