From 6b54db676b15cd853289e2850eebfc8a6a85c558 Mon Sep 17 00:00:00 2001 From: fanjunyang Date: Thu, 26 Jun 2025 16:18:14 +0800 Subject: [PATCH] fix: fixed the Select component not taking keys according to the corresponding value when passing fieldNames. --- components/vc-select/utils/valueUtil.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/vc-select/utils/valueUtil.ts b/components/vc-select/utils/valueUtil.ts index 9e5207de69..ddf571fc4a 100644 --- a/components/vc-select/utils/valueUtil.ts +++ b/components/vc-select/utils/valueUtil.ts @@ -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); } @@ -54,7 +56,7 @@ export function flattenOptions