Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 57ea8a6

Browse files
junyangfanfanjunyang
and
fanjunyang
authored
fix: fixed the Select component not taking keys according to the corresponding value when passing fieldNames. (#8247)
Co-authored-by: fanjunyang <fanjunyang@daojia-inc.com>
1 parent 7e50080 commit 57ea8a6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

‎components/vc-select/utils/valueUtil.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import type { BaseOptionType, DefaultOptionType, RawValueType, FieldNames } from
22
import { warning } from '../../vc-util/warning';
33
import type { FlattenOptionData } from '../interface';
44

5-
function getKey(data: BaseOptionType, index: number) {
5+
function getKey(data: BaseOptionType, index: number,fieldNames?: FieldNames) {
66
const { key } = data;
77
let value: RawValueType;
88

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) {
1012
({ value } = data);
1113
}
1214

@@ -54,7 +56,7 @@ export function flattenOptions<OptionType extends BaseOptionType = DefaultOption
5456
const value = data[fieldValue];
5557
// Option
5658
flattenList.push({
57-
key: getKey(data, flattenList.length),
59+
key: getKey(data, flattenList.length,fieldNames),
5860
groupOption: isGroupOption,
5961
data,
6062
label,
@@ -67,7 +69,7 @@ export function flattenOptions<OptionType extends BaseOptionType = DefaultOption
6769
}
6870
// Option Group
6971
flattenList.push({
70-
key: getKey(data, flattenList.length),
72+
key: getKey(data, flattenList.length,fieldNames),
7173
group: true,
7274
data,
7375
label: grpLabel,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /