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

Step value not passed into ComposedSubmit #2389

Open
JesseMaxwell opened this issue Oct 17, 2024 · 0 comments
Open

Step value not passed into ComposedSubmit #2389

JesseMaxwell opened this issue Oct 17, 2024 · 0 comments

Comments

@JesseMaxwell
Copy link

Describe the Bug

Files:

  1. Problem: node_modules/@graphcommerce/react-hook-form/src/ComposedForm/useFormCompose.ts
  2. Apparent: node_modules/@graphcommerce/react-hook-form/src/ComposedForm/ComposedSubmit.tsx

Description

The step key is not passed in during the ASSIGN dispatch() on Line 21 of: node_modules/@graphcommerce/react-hook-form/src/ComposedForm/useFormCompose.ts. As a result, the forms ignore the expected step ordering.

Solution:

-dispatch({ type: 'ASSIGN', key, form: form as UseFormReturn<FieldValues>, submit })
+dispatch({ type: 'ASSIGN', key, form: form as UseFormReturn<FieldValues>, submit, step })

A TypeScript modification would be necessary as well.

Here's the full.patch file that works:

diff --git a/node_modules/@graphcommerce/react-hook-form/src/ComposedForm/useFormCompose.ts b/node_modules/@graphcommerce/react-hook-form/src/ComposedForm/useFormCompose.ts
index 58aa7a1..627deae 100644
--- a/node_modules/@graphcommerce/react-hook-form/src/ComposedForm/useFormCompose.ts
+++ b/node_modules/@graphcommerce/react-hook-form/src/ComposedForm/useFormCompose.ts
@@ -18,7 +18,7 @@ export function useFormCompose<V extends Record<string, unknown>>(
   }, [dispatch, key, step])
 
   useEffect(() => {
-    dispatch({ type: 'ASSIGN', key, form: form as UseFormReturn<FieldValues>, submit })
+    dispatch({ type: 'ASSIGN', key, form: form as UseFormReturn<FieldValues>, submit, step })
   }, [dispatch, fields, form, key, submit])
 
   const error = isFormGqlOperation(form) ? form.error : undefined

Expected Behavior

The step values are used to build the array. The code is already there to handle this, it's just not receiving the info it needs.

To Reproduce

  1. Adjust the step order.
  2. Place Order with a multi-step, composed form.
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

No branches or pull requests

1 participant