Skip to content

Conversation

@JustinWorobel
Copy link

Purpose
Changing the enabled/disabled behavior of the "Submit" button and the way that the validity styling is displayed on the Harvest form to better align with the convention used in other FarmData2 forms.

Verification steps
Visit "FarmData2" -> "Seeding" -> "Harvest"
Notice: The "Submit" button is enabled. AND Validity styling is not shown on the inputs.
Click Submit
Notice the submit button has been disabled and validity styling is now showing the valid and invalid inputs
Complete the form by providing valid inputs and then notice that the Harvest form submit becomes enabled.

Approach
Adopted the same pattern used in Tray Seeding adding a validity state object that showed a validity flag on each component. We passed the validity styling object into the components so that validity styling did not show until a submit attempt was made. We added two computed properties: validToSubmit, which checks the validity on all of the fields and submitEnabled to check validity before the first submit attempt and then only when validToSubmit returns true. Finally, we updated the submit form to only submit when validToSubmit is true.

Testing
Updated the Cypress Harvest tests to confirm that submit is enabled on the inital loading of the page and that after clicking submit, it disables and does not send if there are any invalid inputs. We then tested to make sure the submit button re-enabled after the inputs in question were filled out.

Related issues
Closes #275

Additional information
Annalee's and Justin's computers were not working and connecting to the code space. They kept getting "unable to connect to server" errors. So all three of us worked off of Youssif's computer and then I wrote the pull request and Justin merged the changes.

Licensing Certification
FarmData2 is a Free Cultural Work and all accepted contributions are licensed as described in the LICENSE.md file. This requires that the contributor holds the rights to do so. By submitting this pull request I certify that I satisfy the terms of the Developer Certificate of Origin for its contents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Harvest form submit button and validity styling behavior

3 participants