feat(account-selector): fire optional onSelectAccount route param on every tap#30318
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 ac85085. Configure here.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Why these tags:
The change is scoped to the route-param callback (not the internal account list selection logic), so the core account switching Redux flow is unchanged. However, any callers that pass Performance Test Selection: |
|



Description
This branch wires up the existing
onSelectAccountroute param onAccountSelectorParamsso callers opening the picker viacreateAccountSelectorNavDetailsreceive a callback on every tap inside the picker — including taps on the already-selected account.Previous behaviour: The
onSelectAccountroute param was declared onAccountSelectorParamsbut never invoked anywhere. Consumers that needed to know "the user committed a selection" had to read Redux state diffs onAccountTreeController:selectedAccountGroupChange, which does not emit when the user re-taps the already-selected account. Combined with the fact that both tap-commit and back-out paths end innavigation.goBack(), callers had no signal to distinguish a same-account commit from a dismiss.New behaviour:
_onSelectMultichainAccountcallssetSelectedAccountGroup(existing behavior), then invokes the route paramonSelectAccount(accountGroup), then closes. The callback fires regardless of whether the controller actually emitted a state change.navigation.goBack()only; callback does NOT fire.Signature updated from
(address: string) => voidto(accountGroup: AccountGroupObject) => voidto match the multichain context. No production caller passes this route param today (verified via repo-wide search forcreateAccountSelectorNavDetails), so this is a safe, additive surface change.Why
What changed (scoped paths)
app/components/Views/AccountSelector/AccountSelector.types.ts— updatedonSelectAccountsignature to(accountGroup: AccountGroupObject) => voidand clarified JSDoc that it fires on every tap.app/components/Views/AccountSelector/AccountSelector.tsx— destructureonSelectAccountfrom route params and invoke inside_onSelectMultichainAccountbetweensetSelectedAccountGroupandhandleClose.app/components/Views/AccountSelector/AccountSelector.test.tsx— 3 new tests: callback fires with the tapped group; callback still fires when re-tapping the already-selected account; picker does not throw when the callback is absent. Updated existing mock's signature.Out of scope (intentional)
onSelectAccountprop (MultichainAccountSelectorList,AccountListCell,AccountConnectSingleSelector, etc.) — none touched.Changelog
CHANGELOG entry: Wired the existing
onSelectAccountroute param on the global Account Selector picker so callers receive a callback on every account tap (including re-tapping the already-selected account), enabling consumer screens to distinguish a committed selection from a dismiss.Related issues
Fixes:
Used by companion PR #30320 (Card spending limit) to detect the "user is exiting Money Account mode by re-tapping the same regular account" case.
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Changes the Account Selector navigation contract by invoking an optional route callback on selection and altering its signature to pass an
AccountGroupObject, which could impact any existing callers and selection flow ordering.Overview
Account Selector now invokes an optional
onSelectAccountroute param on every account tap.AccountSelectorwiresroute.params.onSelectAccountinto_onSelectMultichainAccount, calling it afterAccountTreeController.setSelectedAccountGroupand before closing the sheet, so callers get a commit signal even when re-tapping the already-selected account.API and tests updated.
AccountSelectorParams.onSelectAccountnow receives anAccountGroupObject(instead of an address string) with updated JSDoc, andAccountSelector.test.tsxadds coverage for callback firing (same/different account), ordering vsgoBack, non-callback behavior, dismiss via back arrow, reload flag reset, and sub-screen back navigation.Reviewed by Cursor Bugbot for commit ad94198. Bugbot is set up for automated code reviews on this repo. Configure here.