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: register function don`t return options with shouldUseNativeValidation in 7.44.0 or later #10504

Closed
1 task done
FanManutd opened this issue Jun 7, 2023 · 8 comments
Closed
1 task done
Labels
question Further information is requested

Comments

@FanManutd
Copy link

Version Number

7.44.3

Codesandbox/Expo snack

https://codesandbox.io/s/react-hook-form-7-44-3-4vm9w2?file=/src/App.tsx

Steps to reproduce

  1. Go to CodeSandbox
  2. Open console
  3. Make sure the register function doesn't return passed properties requried, min, and any other

Expected behaviour

In version 7.43.9 (sandox here) the function register with shouldUseNativeValidation: true option returned the passed parameters and I expected this behavior in my code. In 7.44.3 this is not the case. Why has it changed?

What browsers are you seeing the problem on?

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@kotarella1110
Copy link
Member

kotarella1110 commented Jun 7, 2023

@bluebill1049

It seems that the addition of the progressive option has resulted in the deletion of shouldNativeValidation...

...(_options.progressive

This appears to be an unintended change.
In any case, as this is a breaking change, it should be reverted.

Sorry, I misunderstood the situation. This change was intended and not a breaking change. The implementation ensures that native validation correctly even without returning the option.

@kotarella1110
Copy link
Member

kotarella1110 commented Jun 7, 2023

It appears that the change was made to address the following issue.

#10348

commit: 6eb85b7

@FanManutd
Copy link
Author

FanManutd commented Jun 7, 2023

Sorry, I misunderstood the situation. This change was intended and not a breaking change. The implementation ensures that native validation correctly even without returning the option.

So, my case - is this a bug or not? I updated the sendbox to see that the properties are not being passed to input. The form is not submitted if the conditions are not met, but there are no native error messages either.

Also, the type of the register function indicates that it can return an object with options required, disabled, min, max, etc.

If version 7.44.3 behaves correctly in this case, does it mean that when the shouldUseNativeValidation option is enabled, parameters such as disable, required, etc. should be passed to bypass the register function?

@bluebill1049
Copy link
Member

There was a bug fix, please refer to the comment above.

@bluebill1049 bluebill1049 added the question Further information is requested label Jun 7, 2023
@FanManutd
Copy link
Author

FanManutd commented Jun 8, 2023

There was a bug fix, please refer to the comment above.

Ok, is it possible to get the default native error messages without passing a custom property message? Now if I don't pass a message prop, no messages appear at all.

Also, UseFormRegisterReturn type return min, max, required and other validate fields. In what cases should this happen?

export type UseFormRegisterReturn<

At the same time, if a disabled prop is passed to the register function, it will be passed to the final input. I'm not sure how this SHOULD work, so I'm asking questions to see if I can get the default native messages.

@bluebill1049
Copy link
Member

At the same time, if a disabled prop is passed to the register function, it will be passed to the final input. I'm not sure how this SHOULD work, so I'm asking questions to see if I can get the default native messages.

disabled prop is not part of constraint API, hence it doesn't introduce a side effect to the validation issue report above (the original bug).

@Moshyfawn
Copy link
Member

Just FYI related #10492

@roryf
Copy link

roryf commented Jun 22, 2023

Just got stumped by this, only ended up here after looking through source code - far as I can tell the progressive prop is not documented anywhere. 👍🏻 on making it clear how this should behave, it seems like the shouldUseNativeValidation is essentially deprecated and meaningless in client-render context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants