Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue: field named with dot like settings.default_port cause isValidating stuck to true #11749

Closed
1 task done
VasilSvirid opened this issue Apr 4, 2024 · 1 comment
Closed
1 task done

Comments

@VasilSvirid
Copy link

VasilSvirid commented Apr 4, 2024

Version Number

7.51.2

Codesandbox/Expo snack

absent

Steps to reproduce

react-hook-form/src/logic/createFormControl.ts
function _updateIsValidating work incorrect for name with . like settings.default_port or complex.name

const _updateIsValidating = (names?: string[], isValidating?: boolean) => {
   if (_proxyFormState.isValidating || _proxyFormState.validatingFields) {
     (names || Array.from(_names.mount)).forEach((name) => {
       if (name) {
         isValidating
           ? set(_formState.validatingFields, name, isValidating)
           : unset(_formState.validatingFields, name);
       }
     });

     _subjects.state.next({
       validatingFields: _formState.validatingFields,
       isValidating: !isEmptyObject(_formState.validatingFields),
     });
   }
};

set/unset produce object like that - that means isValidating false

{
  "simplename": false
  "complex": {
     "name" : false
  }
}

src/utils/isEmptyObject.ts
but isEmptyObject return false for that object (!isEmptyObject return true and this is cause issue)

export default (value: unknown): value is EmptyObject =>
  isObject(value) && !Object.keys(value).length;

Expected behaviour

names with . like settings.default_port process without isValidating stuck

What browsers are you seeing the problem on?

Chrome, Safari

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@VasilSvirid
Copy link
Author

sorry, check one more time on newer version. fixed

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants