fix: select toValue (#1962)

* fix: select toValue

* fix: select toValue
This commit is contained in:
katherinehhh 2023-05-31 16:55:52 +08:00 committed by GitHub
parent 98be397574
commit ea04d2309e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -79,6 +79,12 @@ const InternalSelect = connect(
if (objectValue) {
return <ObjectSelect {...others} value={value} mode={mode} loading={loading} />;
}
const toValue = (v) => {
if (['tags', 'multiple'].includes(props.mode) || props.multiple) {
return toArr(v);
}
return v;
};
return (
<AntdSelect
showSearch
@ -86,7 +92,7 @@ const InternalSelect = connect(
allowClear
dropdownMatchSelectWidth={false}
notFoundContent={loading ? <Spin /> : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />}
value={value?value:undefined}
value={toValue(value)}
{...others}
onChange={(changed) => {
props.onChange?.(changed === undefined ? null : changed);