-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
base: main
Are you sure you want to change the base?
Conversation
@Centerworx I've seen that you've opened up 2 PR's which are almost identical, not sure which one to look at? |
Sorry about that, fixed. |
src/hook/index.tsx
Outdated
@@ -81,6 +79,10 @@ export const useRemixForm = <T extends FieldValues>({ | |||
validKeys, | |||
); | |||
|
|||
const isValid = !(Object.keys(errors).length > 0); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
src/hook/index.tsx
Outdated
@@ -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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
any updates on this? |
Waiting for feedback on my comments and will be good to merge |
There was a problem hiding this 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.
src/hook/index.tsx
Outdated
@@ -81,6 +79,10 @@ export const useRemixForm = <T extends FieldValues>({ | |||
validKeys, | |||
); | |||
|
|||
const isValid = !(Object.keys(errors).length > 0); |
There was a problem hiding this comment.
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.
src/hook/index.tsx
Outdated
@@ -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; |
There was a problem hiding this comment.
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.
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. |
@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! |
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.
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
Checklist: