feat: select option support number #4570

close #4570
pull/4577/head
tangjinzhou 2021-08-24 23:26:58 +08:00
parent bd553de501
commit 0d41aa929a
2 changed files with 1 additions and 19 deletions

View File

@ -1,7 +1,6 @@
import warning, { noteOnce } from '../../vc-util/warning';
import type { SelectProps } from '..';
import { convertChildrenToData } from './legacyUtil';
import type { OptionData } from '../interface';
import { toArray } from './commonUtil';
import type { RawValueType, LabelValueType } from '../interface/generator';
import { isValidElement } from '../../_util/props-util';
@ -36,23 +35,6 @@ function warningProps(props: SelectProps) {
'Please avoid setting option to disabled in tags mode since user can always type text as tag.',
);
// `combobox` & `tags` should option be `string` type
if (mode === 'tags' || mode === 'combobox') {
const hasNumberValue = mergedOptions.some(item => {
if (item.options) {
return item.options.some(
(opt: OptionData) => typeof ('value' in opt ? opt.value : opt.key) === 'number',
);
}
return typeof ('value' in item ? item.value : item.key) === 'number';
});
warning(
!hasNumberValue,
'`value` of Option should not use number type when `mode` is `tags` or `combobox`.',
);
}
// `combobox` should not use `optionLabelProp`
warning(
mode !== 'combobox' || !optionLabelProp,

2
v2-doc

@ -1 +1 @@
Subproject commit 3f94a02d16bac2377d71e26948ffe45571dae49e
Subproject commit 72a50fb9620defe257ea3f0f3256ed678df98b05