react-hook-form 7.20.4 → 7.20.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +4 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/logic/unsetEmptyArray.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -885,6 +885,8 @@ var skipValidation = (isBlurEvent, isTouched, isSubmitted, reValidateMode, mode)
|
|
885
885
|
return true;
|
886
886
|
};
|
887
887
|
|
888
|
+
var unsetEmptyArray = (ref, name) => !compact(get(ref, name, [])).length && unset(ref, name);
|
889
|
+
|
888
890
|
var isMessage = (value) => isString(value) || React.isValidElement(value);
|
889
891
|
|
890
892
|
var isRegex = (value) => value instanceof RegExp;
|
@@ -1128,11 +1130,13 @@ function createFormControl(props = {}) {
|
|
1128
1130
|
if (Array.isArray(get(_formState.errors, name))) {
|
1129
1131
|
const errors = method(get(_formState.errors, name), args.argA, args.argB);
|
1130
1132
|
shouldSetValues && set(_formState.errors, name, errors);
|
1133
|
+
unsetEmptyArray(_formState.errors, name);
|
1131
1134
|
}
|
1132
1135
|
if (_proxyFormState.touchedFields && get(_formState.touchedFields, name)) {
|
1133
1136
|
const touchedFields = method(get(_formState.touchedFields, name), args.argA, args.argB);
|
1134
1137
|
shouldSetValues &&
|
1135
1138
|
set(_formState.touchedFields, name, touchedFields);
|
1139
|
+
unsetEmptyArray(_formState.touchedFields, name);
|
1136
1140
|
}
|
1137
1141
|
if (_proxyFormState.dirtyFields || _proxyFormState.isDirty) {
|
1138
1142
|
_formState.dirtyFields = getDirtyFields(_defaultValues, _formValues);
|