Skip to content

fix(checkout): CHECKOUT-10180 Initialize checklist formik with correct value#3143

Open
bc-maxy wants to merge 2 commits into
masterfrom
checkout-10180
Open

fix(checkout): CHECKOUT-10180 Initialize checklist formik with correct value#3143
bc-maxy wants to merge 2 commits into
masterfrom
checkout-10180

Conversation

@bc-maxy

@bc-maxy bc-maxy commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What/Why?

This PR fixes the issue when a checkout page is rendered without pre-selected shipping method even though it comes as selected through our initial state.

The issue is that Checklist forwards defaultSelectedItemId to Accordion for visual pre-selection, but never syncs that value into its own Formik field.

Fix: the existing useEffect that runs on mount and unmount now also seeds the Formik field with defaultSelectedItemId on mount, if present.

This Checklist component is also used by Payment method selection, but this PR should not make any difference there. In Payment method selection defaultSelectedItemId comes from Formik, so setting it on mount will be a no-op.

Added tests covering both the seeded and empty-default cases.

Rollout/Rollback

Revert the PR.

Testing

New CI tests + manual testing:

Before

Screen.Recording.2026-07-07.at.2.07.26.PM.mov

After

Screen.Recording.2026-07-07.at.2.12.47.PM.mov

Note

Low Risk
Small UI form sync change in a shared component; payment paths are expected to be no-ops when the value already comes from Formik.

Overview
Fixes checkout shipping (and similar checklist UIs) where the accordion looked pre-selected but the Formlist/Formik field stayed empty because defaultSelectedItemId was only passed to Accordion, not written into Formik.

On mount, the existing cleanup useEffect now also calls setFieldValue(name, defaultSelectedItemId) when that prop is set, so initial server/checkout state matches the form value. Unmount still clears the field. Payment flows that already derive the default from Formik should behave the same.

Reviewed by Cursor Bugbot for commit a9e2487. Bugbot is set up for automated code reviews on this repo. Configure here.

@bc-maxy

bc-maxy commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a9e2487. Configure here.

Comment thread packages/ui/src/form/Checklist/Checklist.tsx
@bc-maxy bc-maxy marked this pull request as ready for review July 7, 2026 04:57
@bc-maxy bc-maxy requested a review from a team as a code owner July 7, 2026 04:57

@bc-peng bc-peng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice detective job👏👏

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.

2 participants