fix: required field delete submit error (#688) (#694)

This commit is contained in:
Ayden 2022-08-03 09:06:50 +08:00 committed by GitHub
parent bc12c92091
commit b9fb69c7aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
import { css } from '@emotion/css'; import { css } from '@emotion/css';
import { FormDialog, FormItem, FormLayout, Input } from '@formily/antd'; 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 { ISchema, Schema, SchemaOptionsContext, useField, useFieldSchema } from '@formily/react';
import { uid } from '@formily/shared'; import { uid } from '@formily/shared';
import { Alert, Button, Dropdown, Menu, MenuItemProps, Modal, Select, Space, Switch } from 'antd'; 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 { confirm, removeParentsIfNoChildren, breakRemoveOn } = props;
const { dn, template } = useSchemaSettings(); const { dn, template } = useSchemaSettings();
const { t } = useTranslation(); const { t } = useTranslation();
const field = useField<Field>();
const fieldSchema = useFieldSchema();
const ctx = useBlockTemplateContext(); const ctx = useBlockTemplateContext();
return ( return (
<SchemaSettings.Item <SchemaSettings.Item
@ -391,6 +393,10 @@ SchemaSettings.Remove = (props: any) => {
removeParentsIfNoChildren, removeParentsIfNoChildren,
breakRemoveOn, breakRemoveOn,
}; };
if (field && field.required) {
field.required = false;
fieldSchema['required'] = false;
}
if (template && ctx?.dn) { if (template && ctx?.dn) {
ctx?.dn.remove(null, options); ctx?.dn.remove(null, options);
} else { } else {