mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
fix(defaultValue): avoid directly displaying variable strings (#6649)
This commit is contained in:
parent
d69fbfeb1b
commit
4bc16e52f2
@ -18,6 +18,7 @@ import { useCollectionFieldUISchema, useIsInNocoBaseRecursionFieldContext } from
|
||||
import { useDynamicComponentProps } from '../../hoc/withDynamicSchemaProps';
|
||||
import { useCompile, useComponent } from '../../schema-component';
|
||||
import { useIsAllowToSetDefaultValue } from '../../schema-settings/hooks/useIsAllowToSetDefaultValue';
|
||||
import { isVariable } from '../../variables/utils/isVariable';
|
||||
import { CollectionFieldProvider, useCollectionField } from './CollectionFieldProvider';
|
||||
|
||||
type Props = {
|
||||
@ -131,7 +132,14 @@ const CollectionFieldInternalField = (props) => {
|
||||
|
||||
if (!uiSchema) return null;
|
||||
|
||||
return <Component {...props} {...dynamicProps} />;
|
||||
const mergedProps = { ...props, ...dynamicProps };
|
||||
|
||||
// Prevent displaying the variable string first, then the variable value
|
||||
if (isVariable(mergedProps.value) && mergedProps.value === fieldSchema.default) {
|
||||
mergedProps.value = undefined;
|
||||
}
|
||||
|
||||
return <Component {...mergedProps} />;
|
||||
};
|
||||
|
||||
export const CollectionField = connect((props) => {
|
||||
|
@ -86,11 +86,6 @@ const useParseDefaultValue = () => {
|
||||
field &&
|
||||
((isVariable(fieldSchema.default) && field.value == null) || field.value === fieldSchema.default || forceUpdate)
|
||||
) {
|
||||
// 一个变量字符串如果显示出来会比较奇怪
|
||||
if (isVariable(field.value)) {
|
||||
await field.reset({ forceClear: true });
|
||||
}
|
||||
|
||||
field.loading = true;
|
||||
const collectionField = !fieldSchema.name.toString().includes('.') && collection?.getField(fieldSchema.name);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user