feat: persist user input values when selected payment method is changed - #1692
Open
Shivam25092001 wants to merge 7 commits into
Open
feat: persist user input values when selected payment method is changed#1692Shivam25092001 wants to merge 7 commits into
Shivam25092001 wants to merge 7 commits into
Conversation
Shivam25092001
requested review from
AbhishekChorotiya,
ArushKapoorJuspay,
aritro2002,
sakksham7 and
seekshiva
as code owners
July 20, 2026 09:37
|
[should-fix] Recompute |
aritro2002
reviewed
Jul 20, 2026
aritro2002
reviewed
Jul 20, 2026
aritro2002
reviewed
Jul 20, 2026
Shivam25092001
force-pushed
the
feat-persist-user-inputs
branch
from
August 7, 2026 10:36
02cdcf1 to
34da08a
Compare
Shivam25092001
had a problem deploying
to
Testing
August 7, 2026 10:37 — with
GitHub Actions
Failure
Shivam25092001
had a problem deploying
to
Testing
August 7, 2026 10:37 — with
GitHub Actions
Failure
Shivam25092001
had a problem deploying
to
Testing
August 24, 2026 08:07 — with
GitHub Actions
Failure
Shivam25092001
had a problem deploying
to
Testing
August 24, 2026 08:07 — with
GitHub Actions
Failure
Shivam25092001
had a problem deploying
to
Testing
August 24, 2026 08:07 — with
GitHub Actions
Failure
Shivam25092001
had a problem deploying
to
Testing
August 24, 2026 08:07 — with
GitHub Actions
Failure
Shivam25092001
dismissed stale reviews from sakksham7 and aritro2002
via
August 24, 2026 12:53
733b78b
Shivam25092001
had a problem deploying
to
Testing
August 24, 2026 12:55 — with
GitHub Actions
Failure
Shivam25092001
had a problem deploying
to
Testing
August 24, 2026 12:55 — with
GitHub Actions
Failure
AbhishekChorotiya
previously approved these changes
Aug 25, 2026
aritro2002
previously approved these changes
Aug 25, 2026
sakksham7
previously approved these changes
Aug 25, 2026
Shivam25092001
dismissed stale reviews from sakksham7, aritro2002, and AbhishekChorotiya
via
August 27, 2026 15:31
c0e5b63
Shivam25092001
had a problem deploying
to
Testing
August 27, 2026 15:32 — with
GitHub Actions
Failure
Shivam25092001
had a problem deploying
to
Testing
August 27, 2026 15:32 — with
GitHub Actions
Failure
Shivam25092001
had a problem deploying
to
Testing
August 27, 2026 15:32 — with
GitHub Actions
Failure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change.
Description
Persists user-entered dynamic field values when the selected payment method type changes, so a shopper who types into shared fields (name, email, phone, address, etc.) doesn't lose that input after switching payment methods.
Why this happens:
In
PaymentElement.resthe payment-method subtree is rendered under<ErrorBoundary key={selectedOption} ...>. Switching the payment method type changes the key and remounts the whole subtree (DynamicFields →ReactFinalForm.Form), destroying all form state. Previously only Country survived, because it round-trips through the persistentuserCountryatom.Changes:
userDynamicFieldsValues : Dict.t<string>inRecoilAtoms.res, keyed byconfirmRequestWritePath. It lives above the remount boundary, so its contents survive the payment-method switch.FormBody'sonFormChange, the typed values of persistable fields are written into the atom every time the form updates.initialValuesWithUserInputOverridememo seeds the form'sinitialValuesfrom the cached atom (layered on top of the existing billing-details override), and the ReactFinalForm.Form now consumes this override.persistableFieldsset — the fields whose values we persist. UnlikemissingRequiredFieldsFiltered(which dedups Email/CardHolderName down to the single visible input), this keeps both name paths (first_name+last_name) and every email path, since the combined name/email inputs write all of them into RFF. It excludes self-managed fields (Country/PhoneCountryCode), which own their value outside RFF and are seeded through their own atom/local-state path.missingRequiredFieldsFilteredfilter into a singlerendersVisibleInputhelper, reused by bothmissingRequiredFieldsFilteredandpersistableFields.No change to the '/confirm' payload shape — seeding stays restricted to the current payment method's rendered fields.
How did you test it?
Manually verified in the SDK: entered values into shared dynamic fields (name / email / phone / address), switched between payment method types, and confirmed the previously typed values are restored on the re-rendered form instead of being wiped.
Screen.Recording.2026-08-06.at.6.18.32.PM.mov
Checklist