question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Form components values - changes in V37.x

See original GitHub issue

Hello,

There’s been a lot of great work in V0.37.x Thank you!

With the recent change to react-hook forms and the Redwood forms package, the behavior is a bit different for empty, non-required fields than before. This was something previously commented on and was changed in April of 2021.

The issue is most easily discussed for a <NumberField>, but it applies to some other types with value transformations as well. With the previous code:

  • A <NumberField> that is set with validation as not required, and an empty field insde would return an undefined for the value.

With the current code:

  • A <NumberField> that is set with validation as not required, and an empty field would will return a NaN for the value.

Our app has numerous non-required fields, and if the <NumberField> is blank, the value gets set to undefined and nothing bad happens on the API side when the object is sent over for a create or update mutation. With a NaN value being returned, this translates to a null over the graphql API. This has caused some bugs for us, but not difficult to fix.

I believe there are arguments for both sides to send back a null vs an undefined in this case.

The new Redwood forms code is definitely more straightforward now, so I see the overall value in the latest code organization. Do we want to: A. Return to undefined as per our discussion and decision from April, and update the code to reflect, or B. Leave the functionality as is currently the case and update the documentation to reflect the new return value?

Please review the original issue and PR for full context.

References: #3376 appears to be the recent change where this took effect. #2162 is the original issue #2167 is the PR where the change was made to undefined values

@jtoar and @Tobbe, can we get your feedback on this? Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
cjreimercommented, Feb 2, 2022

@Tobbe I can work on this! Hopefully this upcoming weekend. I’ll watch for progress and hopefully a merge on your existing PR, and then review what’s left. Does that make sense? Feel free to message me if more detailed coordination would be useful.

1reaction
cjreimercommented, Nov 13, 2021

No problem, @Tobbe. It is not a high priority for us as we have already resolved it. Just a matter of cleaning up this issue in Redwood as the docs don’t match the code for this.

I expect it should be pretty stable for minor r-h-f updates. Right now, our wrapper for r-h-f is one file (~800 lines with comments). It will add some complexity to put this in … I haven’t looked at it in detail yet.

If this can be done with minimal effort, I agree it’s worth it. However, I wouldn’t want to put in hundreds of lines of code, which then need to be maintained, to make it happen if that’s what’s required. So perhaps when I have time at some point, I’ll take a look and see what it would take.

Read more comments on GitHub >

github_iconTop Results From Across the Web

0.28.3 Submitting a form with an empty DateField will throw an ...
The DateField is set as optional by excluding validation={{ required: true }} ... Form components values - changes in V37.x #3609.
Read more >
Changelog - Gradio
When a component's initial value is a function, the every parameter re-runs the function every every seconds. By @abidlabs in PR 2806.
Read more >
Meta Quest release notes
Check out our release notes to learn about the latest new features and enhancements we've made ... These changes will roll out to...
Read more >
EDGAR Filer Manual Volume II - SEC.gov
Use this EDGAR® Filer Manual when making electronic filings with the United States. Securities and Exchange Commission (SEC or “Commission”).
Read more >
MS-DRG Classifications and Software - CMS
For additional information on the MS-DRG system, including yearly reviews and changes to the MS-DRGs, please view prior Inpatient Prospective Payment System ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found