fix: hiding the title of a subform will hide all embedded titles (#1904)
* fix: hiding the title of a subform will hide all embedded titles * fix: display title not immediately effective
This commit is contained in:
parent
0318034b7c
commit
d0f2bd96a8
@ -84,7 +84,7 @@ export const FormItem: any = observer((props: any) => {
|
||||
`,
|
||||
{
|
||||
[css`
|
||||
& .ant-formily-item-label {
|
||||
> .ant-formily-item-label {
|
||||
display: none;
|
||||
}
|
||||
`]: showTitle === false,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Field } from '@formily/core';
|
||||
import { ISchema, useField, useFieldSchema } from '@formily/react';
|
||||
import { ISchema, useField, useFieldSchema,observer } from '@formily/react';
|
||||
import _ from 'lodash';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import React from 'react';
|
||||
@ -9,7 +9,7 @@ import { SchemaSettings } from '../schema-settings';
|
||||
|
||||
export const GeneralSchemaItems: React.FC<{
|
||||
required?: boolean;
|
||||
}> = (props) => {
|
||||
}> = observer((props) => {
|
||||
const { required = true } = props;
|
||||
const { getCollectionJoinField } = useCollectionManager();
|
||||
const { getField } = useCollection();
|
||||
@ -18,7 +18,7 @@ export const GeneralSchemaItems: React.FC<{
|
||||
const { t } = useTranslation();
|
||||
const { dn, refresh } = useDesignable();
|
||||
const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
|
||||
|
||||
console.log(field,field.decoratorProps )
|
||||
return (
|
||||
<>
|
||||
{collectionField && (
|
||||
@ -60,6 +60,8 @@ export const GeneralSchemaItems: React.FC<{
|
||||
checked={field.decoratorProps.showTitle ?? true}
|
||||
title={t('Display title')}
|
||||
onChange={(checked) => {
|
||||
fieldSchema['x-decorator-props'] = fieldSchema['x-decorator-props'] || {};
|
||||
fieldSchema['x-decorator-props']['showTitle'] = checked;
|
||||
field.decoratorProps.showTitle = checked;
|
||||
dn.emit('patch', {
|
||||
schema: {
|
||||
@ -158,4 +160,4 @@ export const GeneralSchemaItems: React.FC<{
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user