-
Notifications
You must be signed in to change notification settings - Fork 970
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
Minor form improvements #9050
Minor form improvements #9050
Conversation
@jtoar , what's the next step to get this reviewed? Thanks! |
Thanks for your PR @cjreimer. I'll take a look as soon as I find some time (next few days hopefully) |
✅ Confirmed and verified
✅ Confirmed and verified
Couldn't get TS to play nice in VS code for this one 🙁 I'll have to try again tomorrow because I need to go sleep now EDIT: ✅ now confirmed and verified |
Thanks, Tobbe, for reviewing! |
@cjreimer Thanks for these changes. They work great when I test on a local project, but tests seems to be failing (also locally). Could you take a look at those failing tests please? |
@Tobbe, thanks for reviewing.
and I believe this is the reason why the tests are failing now. I believe we can get rid of these lines, as you propose, if we migrate to I played with this, and I seem to remember I had this working with the forms package, but the CI checks complain if the redwood packages don't all match up (fair enough), so I wasn't sure if we wanted to do a major jest-dom upgrade in this small pr, and pulled that back, which meant returning those import lines and the Thoughts? |
@cjreimer It was giving TS errors, and removing it solved that. And it still built. So I thought things were still working. I read something somewhere about that stuff being automatically included. But as you said - might be we're on a too old version. Feel free to revert my changes there if that gets things passing, and then we can loop back on fixing the red squiggles later |
Head branch was pushed to by a user without write access
No problem. I just reverted all the matches, and the tests once again pass. |
This PR addresses three minor items with the forms package: 1. If using on a field the `validation={{valueAsNumber: true}}` feature, and `emptyAs` is set to `'undefined'`, the react-hook-form would override the `emptyAs`. The solution is to remove the `valueAsNumber` internally in this case and rely on the `setValueAs` coersion we have in redwood. 2. If the `name` field is not set on a field component, the error would be deep from within react-hook-forms and unintelligible. A change is made to throw an intelligible error `"name field must be provided"`. While typescript should normally help with this, not everyone uses typescript, and I have been burned by this one even using typescript. 3. Fixed a typescript warning relating to a `ref` in the test file. --------- Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
This PR addresses three minor items with the forms package:
If using on a field the
validation={{valueAsNumber: true}}
feature, andemptyAs
is set to'undefined'
, the react-hook-form would override theemptyAs
. The solution is to remove thevalueAsNumber
internally in this case and rely on thesetValueAs
coersion we have in redwood.If the
name
field is not set on a field component, the error would be deep from within react-hook-forms and unintelligible. A change is made to throw an intelligible error"name field must be provided"
. While typescript should normally help with this, not everyone uses typescript, and I have been burned by this one even using typescript.Fixed a typescript warning relating to a
ref
in the test file.