Skip to content

fix(ep-commerce): provide FormProvider from EP Product Provider - #409

Open
mzaintariq wants to merge 1 commit into
masterfrom
fix/ep-product-provider-form-provider
Open

fix(ep-commerce): provide FormProvider from EP Product Provider#409
mzaintariq wants to merge 1 commit into
masterfrom
fix/ep-product-provider-form-provider

Conversation

@mzaintariq

Copy link
Copy Markdown
Collaborator

What does this MR do?

Mounts a react-hook-form FormProvider inside EPProductProvider, matching commerce Product Box’s contract. Without it, descendants that write selection via form context (SelectedLocationSlug, variants, quantity for ATC) silently no-op when the PDP uses EP Product Provider instead of Product Box.

Changes

  • Wrap provider children in FormProvider from useForm()
  • Reset form state when the product id changes
  • Doc comment clarifying parity with commerce ProductProvider

Design decisions

  • EP Product Provider is the SSR-friendly product context; location picker / ATC already assume form context (“must be inside a Product Box”)
  • Product Box already provides FormProvider; this closes the gap for compositions that only use EP Product Provider
  • Cart drawer qty/remove do not depend on this — they use cart line data, not PDP form state

Testing

  • Manual: PDP with EP Product Provider + location radios — selecting a location updates selection / URL and ATC receives location
  • No change expected for Product Box–based PDPs (nested form providers remain the existing composition)

Reviewer notes

  • Independent of cart drawer designer-error work; no dependency on that PR
  • Follow-up found while testing multilocation ATC → cart; not required for cart-error DataProviders
  • Consider a small unit/integration test later if we want FormProvider presence covered in CI

Match commerce Product Box so location/variant/quantity form state is shared with Add To Cart; without it, EPLocationPicker clicks are no-ops.
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.

1 participant