fix: "Select from existing data" still showing when disable “Allow mu… (#6167)

* fix: "Select from existing data" still showing when disable “Allow multiple ” in to-many subform

* fix: bug
This commit is contained in:
Katherine 2025-02-07 17:03:38 +08:00 committed by GitHub
parent cd50adcf5e
commit 435dc80a78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 6 deletions

View File

@ -2,9 +2,7 @@
"version": "1.6.0-alpha.22", "version": "1.6.0-alpha.22",
"npmClient": "yarn", "npmClient": "yarn",
"useWorkspaces": true, "useWorkspaces": true,
"npmClientArgs": [ "npmClientArgs": ["--ignore-engines"],
"--ignore-engines"
],
"command": { "command": {
"version": { "version": {
"forcePublish": true, "forcePublish": true,

View File

@ -15,7 +15,7 @@ import { useTranslation } from 'react-i18next';
import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings'; import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings';
import { useCollectionManager_deprecated, useSortFields } from '../../../../collection-manager'; import { useCollectionManager_deprecated, useSortFields } from '../../../../collection-manager';
import { useFieldComponentName } from '../../../../common/useFieldComponentName'; import { useFieldComponentName } from '../../../../common/useFieldComponentName';
import { useCollectionManager, useRerenderDataBlock } from '../../../../data-source'; import { useCollectionManager, useRerenderDataBlock, useCollectionField } from '../../../../data-source';
import { FlagProvider } from '../../../../flag-provider/FlagProvider'; import { FlagProvider } from '../../../../flag-provider/FlagProvider';
import { withDynamicSchemaProps } from '../../../../hoc/withDynamicSchemaProps'; import { withDynamicSchemaProps } from '../../../../hoc/withDynamicSchemaProps';
import { import {
@ -76,8 +76,11 @@ export const allowSelectExistingRecord = {
name: 'allowSelectExistingRecord', name: 'allowSelectExistingRecord',
type: 'switch', type: 'switch',
useVisible() { useVisible() {
const fieldSchema = useFieldSchema();
const { multiple } = fieldSchema['x-component-props'];
const readPretty = useIsFieldReadPretty(); const readPretty = useIsFieldReadPretty();
return !readPretty; const collectionField = useCollectionField();
return !readPretty && multiple !== false && ['hasMany', 'belongsToMany'].includes(collectionField?.type);
}, },
useComponentProps() { useComponentProps() {
const { t } = useTranslation(); const { t } = useTranslation();

View File

@ -322,7 +322,7 @@ const ToManyNester = observer(
} }
/> />
)} )}
{field.editable && allowSelectExistingRecord && currentMode === 'Nester' && ( {field.editable && allowSelectExistingRecord && currentMode === 'Nester' && allowMultiple && (
<Action.Link <Action.Link
useAction={useNesterSelectProps} useAction={useNesterSelectProps}
title={ title={