@bombillazo/rhf-plus 7.71.0-plus.0 → 7.71.2-plus.4

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.
@@ -2278,11 +2278,24 @@ function createFormControl(props = {}) {
2278
2278
  isFocused: (formState || _formState).focusedField === name,
2279
2279
  });
2280
2280
  const clearErrors = (name) => {
2281
- name &&
2282
- convertToArrayPayload(name).forEach((inputName) => unset(_formState.errors, inputName));
2283
- _subjects.state.next({
2284
- errors: name ? _formState.errors : {},
2285
- });
2281
+ const names = name ? convertToArrayPayload(name) : undefined;
2282
+ names === null || names === void 0 ? void 0 : names.forEach((inputName) => unset(_formState.errors, inputName));
2283
+ if (names) {
2284
+ // Emit for each cleared field with the field name so that
2285
+ // shouldSubscribeByName can filter and avoid broad re-renders
2286
+ names.forEach((inputName) => {
2287
+ _subjects.state.next({
2288
+ name: inputName,
2289
+ errors: _formState.errors,
2290
+ });
2291
+ });
2292
+ }
2293
+ else {
2294
+ // Clear all errors - emit without name to notify all subscribers
2295
+ _subjects.state.next({
2296
+ errors: {},
2297
+ });
2298
+ }
2286
2299
  };
2287
2300
  const setError = (name, error, options) => {
2288
2301
  const ref = (get(_fields, name, { _f: {} })._f || {}).ref;