fix: select with color tag value (#1963)

* fix: select with color tag value

* fix: select with color tag value
This commit is contained in:
katherinehhh 2023-05-31 22:20:06 +08:00 committed by GitHub
parent 78095d1128
commit e139646d65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -206,6 +206,7 @@ const InternalRemoteSelect = connect(
{...others}
loading={data! ? loading : true}
options={mapOptionsToTags(options)}
rawOptions={options}
/>
);
},

View File

@ -7,12 +7,17 @@ import React from 'react';
import { ReadPretty } from './ReadPretty';
import { defaultFieldNames, getCurrentOptions } from './shared';
type Props = SelectProps<any, any> & { objectValue?: boolean; onChange?: (v: any) => void; multiple: boolean };
type Props = SelectProps<any, any> & {
objectValue?: boolean;
onChange?: (v: any) => void;
multiple: boolean;
rawOptions: any[];
};
const isEmptyObject = (val: any) => !isValid(val) || (typeof val === 'object' && Object.keys(val).length === 0);
const ObjectSelect = (props: Props) => {
const { value, options, onChange, fieldNames, mode, loading, ...others } = props;
const { value, options, onChange, fieldNames, mode, loading, rawOptions, ...others } = props;
const toValue = (v: any) => {
if (isEmptyObject(v)) {
return;
@ -52,7 +57,7 @@ const ObjectSelect = (props: Props) => {
onChange={(changed) => {
const current = getCurrentOptions(
toArr(changed).map((v) => v.value),
options,
rawOptions,
fieldNames,
);
if (['tags', 'multiple'].includes(mode) || props.multiple) {