rsuite 5.70.2 → 5.70.3

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.
@@ -6,7 +6,7 @@ export interface FormErrorProps {
6
6
  onError?: (formError: any) => void;
7
7
  nestedField?: boolean;
8
8
  }
9
- export default function useFormValidate(formError: any, props: FormErrorProps): {
9
+ export default function useFormValidate(_formError: any, props: FormErrorProps): {
10
10
  formError: any;
11
11
  check: (...args: any[]) => any;
12
12
  checkForField: (...args: any[]) => any;
@@ -8,13 +8,13 @@ import omit from 'lodash/omit';
8
8
  import set from 'lodash/set';
9
9
  import { useControlled, useEventCallback } from "../../internals/hooks/index.js";
10
10
  import { nameToPath } from "../../FormControl/utils.js";
11
- export default function useFormValidate(formError, props) {
11
+ export default function useFormValidate(_formError, props) {
12
12
  var formValue = props.formValue,
13
13
  getCombinedModel = props.getCombinedModel,
14
14
  onCheck = props.onCheck,
15
15
  onError = props.onError,
16
16
  nestedField = props.nestedField;
17
- var _useControlled = useControlled(formError, {}),
17
+ var _useControlled = useControlled(_formError, {}),
18
18
  realFormError = _useControlled[0],
19
19
  setFormError = _useControlled[1];
20
20
  var checkOptions = {
@@ -68,7 +68,7 @@ export default function useFormValidate(formError, props) {
68
68
  var checkFieldForNextValue = useEventCallback(function (fieldName, nextValue, callback) {
69
69
  var model = getCombinedModel();
70
70
  var resultOfCurrentField = model.checkForField(fieldName, nextValue, checkOptions);
71
- var nextFormError = _extends({}, formError);
71
+ var nextFormError = _extends({}, realFormError);
72
72
  /**
73
73
  * when using proxy of schema-typed, we need to use getCheckResult to get all errors,
74
74
  * but if nestedField is used, it is impossible to distinguish whether the nested object has an error here,
@@ -151,7 +151,7 @@ export default function useFormValidate(formError, props) {
151
151
  var checkFieldAsyncForNextValue = useEventCallback(function (fieldName, nextValue) {
152
152
  var model = getCombinedModel();
153
153
  return model.checkForFieldAsync(fieldName, nextValue, checkOptions).then(function (resultOfCurrentField) {
154
- var nextFormError = _extends({}, formError);
154
+ var nextFormError = _extends({}, realFormError);
155
155
  /**
156
156
  * when using proxy of schema-typed, we need to use getCheckResult to get all errors,
157
157
  * but if nestedField is used, it is impossible to distinguish whether the nested object has an error here,
@@ -220,7 +220,7 @@ export default function useFormValidate(formError, props) {
220
220
  setFormError(formError);
221
221
  });
222
222
  var cleanErrorForField = useEventCallback(function (fieldName) {
223
- setFormError(omit(formError, [nestedField ? nameToPath(fieldName) : fieldName]));
223
+ setFormError(omit(realFormError, [nestedField ? nameToPath(fieldName) : fieldName]));
224
224
  });
225
225
  return {
226
226
  formError: realFormError,
@@ -85,8 +85,14 @@ function useFlattenTree(data, options) {
85
85
  updateTreeNodeCheckState(value);
86
86
  forceUpdate();
87
87
  }
88
+
89
+ /**
90
+ * Add a dependency on data, because when loading data asynchronously through getChildren,
91
+ * data may change and the node status needs to be updated.
92
+ * @see https://github.com/rsuite/rsuite/issues/3973
93
+ */
88
94
  // eslint-disable-next-line react-hooks/exhaustive-deps
89
- }, [value]);
95
+ }, [value, data]);
90
96
  return flattenedNodes.current;
91
97
  }
92
98
  export default useFlattenTree;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rsuite",
3
- "version": "5.70.2",
3
+ "version": "5.70.3",
4
4
  "description": "A suite of react components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",