Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions components/vc-select/utils/valueUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import type { BaseOptionType, DefaultOptionType, RawValueType, FieldNames } from
import { warning } from '../../vc-util/warning';
import type { FlattenOptionData } from '../interface';

function getKey(data: BaseOptionType, index: number) {
function getKey(data: BaseOptionType, index: number, fieldNames?: FieldNames) {
const { key } = data;
let value: RawValueType;

if ('value' in data) {
if (fieldNames && fieldNames.value && data[fieldNames.value] !== undefined) {
({ [fieldNames.value]: value } = data);
} else if ('value' in data) {
({ value } = data);
}

Expand Down Expand Up @@ -54,7 +56,7 @@ export function flattenOptions<OptionType extends BaseOptionType = DefaultOption
const value = data[fieldValue];
// Option
flattenList.push({
key: getKey(data, flattenList.length),
key: getKey(data, flattenList.length, fieldNames),
groupOption: isGroupOption,
data,
label,
Expand All @@ -67,7 +69,7 @@ export function flattenOptions<OptionType extends BaseOptionType = DefaultOption
}
// Option Group
flattenList.push({
key: getKey(data, flattenList.length),
key: getKey(data, flattenList.length, fieldNames),
group: true,
data,
label: grpLabel,
Expand Down