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

2
package.json

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

Loading…
Cancel
Save