@gridsuite/commons-ui 0.120.0 → 0.120.1

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.
@@ -61,28 +61,39 @@ function useUniqueNameValidation({
61
61
  );
62
62
  const debouncedHandleCheckName = useDebounce(handleCheckName, 700);
63
63
  useEffect(() => {
64
- var _a2, _b;
65
- const trimmedValue = (_a2 = value == null ? void 0 : value.trim) == null ? void 0 : _a2.call(value);
66
- if (!trimmedValue && isDirty) {
67
- clearErrors("root.isValidating");
68
- setError(name, {
69
- type: "validate",
70
- message: "nameEmpty"
71
- });
72
- return;
64
+ const trimmedValue = value.trim();
65
+ if (selectedDirectory) {
66
+ debouncedHandleCheckName(trimmedValue);
73
67
  }
74
- if (!isDirty || ((_b = defaultFieldValue == null ? void 0 : defaultFieldValue.trim) == null ? void 0 : _b.call(defaultFieldValue)) === trimmedValue) {
68
+ if (!isDirty) {
75
69
  clearErrors(name);
76
70
  return;
77
71
  }
78
- setError("root.isValidating", {
79
- type: "validate",
80
- message: "cantSubmitWhileValidating"
81
- });
82
- if (directory) {
72
+ if (trimmedValue) {
73
+ clearErrors(name);
74
+ setError("root.isValidating", {
75
+ type: "validate",
76
+ message: "cantSubmitWhileValidating"
77
+ });
83
78
  debouncedHandleCheckName(trimmedValue);
79
+ } else {
80
+ clearErrors("root.isValidating");
81
+ setError(name, {
82
+ type: "validate",
83
+ message: "nameEmpty"
84
+ });
84
85
  }
85
- }, [value, debouncedHandleCheckName, setError, clearErrors, name, isDirty, defaultFieldValue, directory]);
86
+ }, [
87
+ value,
88
+ debouncedHandleCheckName,
89
+ setError,
90
+ clearErrors,
91
+ name,
92
+ isDirty,
93
+ defaultFieldValue,
94
+ directory,
95
+ selectedDirectory
96
+ ]);
86
97
  return {
87
98
  isValidating
88
99
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.120.0",
3
+ "version": "0.120.1",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",