From b9fb69c7aa0e9ebbf80b04a64686328fe9fa12e6 Mon Sep 17 00:00:00 2001 From: Ayden Date: Wed, 3 Aug 2022 09:06:50 +0800 Subject: [PATCH] fix: required field delete submit error (#688) (#694) --- .../core/client/src/schema-settings/SchemaSettings.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/core/client/src/schema-settings/SchemaSettings.tsx b/packages/core/client/src/schema-settings/SchemaSettings.tsx index f03580fae..4ec2587a7 100644 --- a/packages/core/client/src/schema-settings/SchemaSettings.tsx +++ b/packages/core/client/src/schema-settings/SchemaSettings.tsx @@ -1,6 +1,6 @@ import { css } from '@emotion/css'; import { FormDialog, FormItem, FormLayout, Input } from '@formily/antd'; -import { createForm, GeneralField } from '@formily/core'; +import { createForm, Field, GeneralField } from '@formily/core'; import { ISchema, Schema, SchemaOptionsContext, useField, useFieldSchema } from '@formily/react'; import { uid } from '@formily/shared'; import { Alert, Button, Dropdown, Menu, MenuItemProps, Modal, Select, Space, Switch } from 'antd'; @@ -378,6 +378,8 @@ SchemaSettings.Remove = (props: any) => { const { confirm, removeParentsIfNoChildren, breakRemoveOn } = props; const { dn, template } = useSchemaSettings(); const { t } = useTranslation(); + const field = useField(); + const fieldSchema = useFieldSchema(); const ctx = useBlockTemplateContext(); return ( { removeParentsIfNoChildren, breakRemoveOn, }; + if (field && field.required) { + field.required = false; + fieldSchema['required'] = false; + } if (template && ctx?.dn) { ctx?.dn.remove(null, options); } else {