@@ -2,11 +2,13 @@ import type { BaseOptionType, DefaultOptionType, RawValueType, FieldNames } from
2
2
import { warning } from '../../vc-util/warning' ;
3
3
import type { FlattenOptionData } from '../interface' ;
4
4
5
- function getKey ( data : BaseOptionType , index : number ) {
5
+ function getKey ( data : BaseOptionType , index : number , fieldNames ?: FieldNames ) {
6
6
const { key } = data ;
7
7
let value : RawValueType ;
8
8
9
- if ( 'value' in data ) {
9
+ if ( fieldNames && fieldNames . value && data [ fieldNames . value ] !== undefined ) {
10
+ ( { [ fieldNames . value ] : value } = data ) ;
11
+ } else if ( 'value' in data ) {
10
12
( { value } = data ) ;
11
13
}
12
14
@@ -54,7 +56,7 @@ export function flattenOptions<OptionType extends BaseOptionType = DefaultOption
54
56
const value = data [ fieldValue ] ;
55
57
// Option
56
58
flattenList . push ( {
57
- key : getKey ( data , flattenList . length ) ,
59
+ key : getKey ( data , flattenList . length , fieldNames ) ,
58
60
groupOption : isGroupOption ,
59
61
data,
60
62
label,
@@ -67,7 +69,7 @@ export function flattenOptions<OptionType extends BaseOptionType = DefaultOption
67
69
}
68
70
// Option Group
69
71
flattenList . push ( {
70
- key : getKey ( data , flattenList . length ) ,
72
+ key : getKey ( data , flattenList . length , fieldNames ) ,
71
73
group : true ,
72
74
data,
73
75
label : grpLabel ,
0 commit comments