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

fixes bug with isValid & isSubmitted states #33

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Centerworx
Copy link

@Centerworx Centerworx commented Oct 8, 2023

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

If this is a new feature please add a description of what was added and why below:

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit tests - Note, The test expected value was incorrect as with no errors {} isValid should be true.

Checklist:

  • My code follows the guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@AlemTuzlak
Copy link
Contributor

@Centerworx I've seen that you've opened up 2 PR's which are almost identical, not sure which one to look at?

@Centerworx
Copy link
Author

Sorry about that, fixed.

@@ -81,6 +79,10 @@ export const useRemixForm = <T extends FieldValues>({
validKeys,
);

const isValid = !(Object.keys(errors).length > 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be formErrors?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should make a difference but I'm updated it.

@@ -81,6 +79,10 @@ export const useRemixForm = <T extends FieldValues>({
validKeys,
);

const isValid = !(Object.keys(errors).length > 0);
const isSubmitted =
data && Object.keys(data).length > 0 && isValid ? true : false;
Copy link
Contributor

@AlemTuzlak AlemTuzlak Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just do Object.keys(data??{}).length > 0 && isValid

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also when is isSubmitted set again? After the submission regardless if its valid or not?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is submited is set as soon as the form is submitted. It will stay submitted until reset is called. So this should be isSubmittedSuccessfully instead.

@flixoflax
Copy link

any updates on this?

@AlemTuzlak
Copy link
Contributor

Waiting for feedback on my comments and will be good to merge

Copy link
Author

@Centerworx Centerworx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should double check the test are still passing, but I made the changes.

@@ -81,6 +79,10 @@ export const useRemixForm = <T extends FieldValues>({
validKeys,
);

const isValid = !(Object.keys(errors).length > 0);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should make a difference but I'm updated it.

@@ -81,6 +79,10 @@ export const useRemixForm = <T extends FieldValues>({
validKeys,
);

const isValid = !(Object.keys(errors).length > 0);
const isSubmitted =
data && Object.keys(data).length > 0 && isValid ? true : false;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is submited is set as soon as the form is submitted. It will stay submitted until reset is called. So this should be isSubmittedSuccessfully instead.

@Centerworx
Copy link
Author

Also, unfortunately remix run is not were I need it to be to work with my project. So I will not be working with it for the forceable future. Feel free to take over this change.

@AlemTuzlak
Copy link
Contributor

@Centerworx Thank you so much for the work you put in and the feedback! I really do appreciate it even though my time is spread very thin and takes me a while to respond. I wish you the best of luck!

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.

3 participants