fix(core): support required custom customer fields in Account Settings#3076
Conversation
🦋 Changeset detectedLatest commit: 1baf556 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Bundle Size ReportComparing against baseline from
Per-Route First Load JS
|
Unlighthouse Performance Comparison — VercelComparing PR preview deployment Unlighthouse scores vs production Unlighthouse scores. Summary ScoreAggregate score across all categories as reported by Unlighthouse.
Category Scores
Core Web Vitals
|
BigCommerce revalidates required custom customer fields on every updateCustomer call, even fields that already have a stored value. Account Settings only ever submitted firstName/lastName/email/company, so any store with a merchant-defined required custom customer field (e.g. a Terms and Conditions checkbox added after accounts already existed) locked customers out of saving any change at all. This restores custom-field support (dropped in b14180c when the page was migrated to Vibes) by reusing the existing DynamicForm/ formFieldTransformer pattern already used by Register and Address, so required fields render, prefill from stored values, and get resent on every save alongside the fixed fields. Fixes #3074 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
0519625 to
1baf556
Compare
| return { ...field, defaultValue: value }; | ||
|
|
||
| default: | ||
| return field; |
There was a problem hiding this comment.
Just checking, do we want default to return the field?
There was a problem hiding this comment.
Yeah we do as we need to map the form submission with some field and we need the field regardless of the default value.

What/Why?
Fixes #3074.
The issue reports two problems with Account Settings' update-customer flow:
firstName/lastName, droppingemail/company. This turned out to be a misread of the code — the lines cited are the mutation's response selection, not the input.submission.value(validated againstupdateAccountSchema) already includesemail/company, and I confirmed via direct GraphQL calls against a test store that both persist correctly today. No fix needed for this part.updateCustomercall — even fields that already have a stored value. A customer with afirstName-only edit getsValidationError: Required account form field ID X is missingif that field isn't resent, regardless of whether it was previously set. Account Settings only ever submittedfirstName/lastName/email/company, so any store with a required custom customer field (e.g. a "Terms and Conditions" checkbox added after accounts already existed) locked customers out of saving any change at all.This is a regression: custom/dynamic form-field support existed in Account Settings since #1257 (Aug 2024) but was dropped during the Vibes migration (
b14180c4, Dec 2024) and never restored, while Register and Address kept it via the newerDynamicForm/formFieldTransformerpattern.This PR restores that support in Account Settings by reusing the same
DynamicForm/formFieldTransformerpattern already used by Register and Address:page-data.tsxnow fetches the customer's existing custom form field values (customer.formFields) alongside the field definitions it already fetched but never used.page.tsxfilters out fields already covered by the fixed inputs (email, password, name, company, phone, newsletter checkbox) and transforms the rest intoFields, pre-filled with the customer's current values.update-account-form.tsxrenders those fields in the same form as the existing firstName/lastName/email/company inputs (via the sharedDynamicFormFieldrenderer), so a single save always resubmits the full required-field state — required given BigCommerce's per-call revalidation.update-customer.tsbuilds the mutation'sformFieldsinput from whatever fields are present, following the same per-type mapping already used byregisterCustomer/updateAddress.dynamic-form/schema.ts(getFieldsShape) so Account Settings' schema can merge the fixed fields with the dynamic ones without duplicating per-field-type zod logic.Testing
email/companyalready persist correctly via the existing mutation input.updateCustomerfails withValidationError, even when the customer already has a stored value for it — confirming the bug and that the fix must always resend it./account/settingswith an authenticated session: confirmed the custom checkbox renders alongside the fixed fields, correctly prefilled from the customer's stored value (checked), and that email/company also prefill from live data.pnpm run typecheckandpnpm run lintpass.Migration
N/A — no breaking changes.
updateAccountSchemachanged from aZodObjectto a factory function; only relevant to direct importers of@/vibes/soul/sections/account-settings/schema.