Browse Source

fix: bump field form version to fix onFieldsChange times not correct (#42263)

* chore: bump field form version

* chore: fix ts
pull/42351/head
二货爱吃白萝卜 2 years ago
committed by GitHub
parent
commit
94339fb8c3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      components/form/FormItem/index.tsx
  2. 2
      package.json

11
components/form/FormItem/index.tsx

@ -83,6 +83,7 @@ function genEmptyMeta(): Meta {
warnings: [],
touched: false,
validating: false,
validated: false,
name: [],
};
}
@ -158,7 +159,7 @@ function InternalFormItem<Values = any>(props: FormItemProps<Values>): React.Rea
// >>>>> Collect noStyle Field error to the top FormItem
const onSubItemMetaChange = (subMeta: Meta & { destroy: boolean }, uniqueKeys: React.Key[]) => {
// Only `noStyle` sub item will trigger
setSubFieldErrors(prevSubFieldErrors => {
setSubFieldErrors((prevSubFieldErrors) => {
const clone = {
...prevSubFieldErrors,
};
@ -184,7 +185,7 @@ function InternalFormItem<Values = any>(props: FormItemProps<Values>): React.Rea
const errorList: string[] = [...meta.errors];
const warningList: string[] = [...meta.warnings];
Object.values(subFieldErrors).forEach(subFieldError => {
Object.values(subFieldErrors).forEach((subFieldError) => {
errorList.push(...(subFieldError.errors || []));
warningList.push(...(subFieldError.warnings || []));
});
@ -254,7 +255,7 @@ function InternalFormItem<Values = any>(props: FormItemProps<Values>): React.Rea
? required
: !!(
rules &&
rules.some(rule => {
rules.some((rule) => {
if (rule && typeof rule === 'object' && rule.required && !rule.warningOnly) {
return true;
}
@ -294,7 +295,7 @@ function InternalFormItem<Values = any>(props: FormItemProps<Values>): React.Rea
warning(
!hasName,
'Form.Item',
"A `Form.Item` with a render function cannot be a field, and thus cannot have a `name` prop.",
'A `Form.Item` with a render function cannot be a field, and thus cannot have a `name` prop.',
);
} else if (dependencies && !isRenderProps && !hasName) {
warning(
@ -343,7 +344,7 @@ function InternalFormItem<Values = any>(props: FormItemProps<Values>): React.Rea
...toArray(mergedValidateTrigger),
]);
triggers.forEach(eventName => {
triggers.forEach((eventName) => {
childProps[eventName] = (...args: any[]) => {
mergedControl[eventName]?.(...args);
children.props[eventName]?.(...args);

2
package.json

@ -131,7 +131,7 @@
"rc-dialog": "~9.0.2",
"rc-drawer": "~6.1.0",
"rc-dropdown": "~4.0.0",
"rc-field-form": "~1.27.0",
"rc-field-form": "~1.30.0",
"rc-image": "~5.13.0",
"rc-input": "~0.1.4",
"rc-input-number": "~7.3.9",

Loading…
Cancel
Save