fix: handle single value selection in multiple mode (#7100)

This commit is contained in:
Zeke Zhang 2025-06-19 15:28:30 +08:00 committed by GitHub
parent 5e83e2b82b
commit 77246e6de2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,12 +13,12 @@ import { isValid, toArr } from '@formily/shared';
import { isPlainObject } from '@nocobase/utils/client';
import type { SelectProps as AntdSelectProps } from 'antd';
import { Select as AntdSelect, Empty, Spin, Tag } from 'antd';
import React from 'react';
import { BaseOptionType, DefaultOptionType } from 'antd/es/select';
import { every } from 'lodash';
import React, { useEffect } from 'react';
import { useCompile } from '../../';
import { ReadPretty } from './ReadPretty';
import { FieldNames, defaultFieldNames, getCurrentOptions } from './utils';
import { BaseOptionType, DefaultOptionType } from 'antd/es/select';
import { useCompile } from '../../';
export type SelectProps<
ValueType = any,
@ -127,6 +127,13 @@ const InternalSelect = connect(
if (mode && !['multiple', 'tags'].includes(mode)) {
mode = undefined;
}
useEffect(() => {
if (value != null && !Array.isArray(value) && (['tags', 'multiple'].includes(props.mode) || props.multiple)) {
props.onChange?.([value]);
}
}, [value, props.mode, props.multiple, props.onChange]);
if (objectValue) {
return (
<ObjectSelect