Skip to content

Commit cc9c67a

Browse files
authored
fix: remove browser navigation on account click when in initial connection flow (#22604)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This PR removes browser navigation when a user clicks the account group in the initial connection flow. <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: Fixes navigation on account group click in initial connection flow ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/WAPI-829 ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user clicks account group Given it's on initial connection flow When user clicks account group Then selected account is changed, and no navigation to in app browser happens ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** https://github.com/user-attachments/assets/fc58a302-7177-4d14-90c0-4b73a89eecf6 <!-- [screenshots/recordings] --> ### **After** https://github.com/user-attachments/assets/d1a079aa-74bc-43e1-925d-cc4c964e1bec <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Selecting an account during the initial connection flow now only updates the selected account group without showing a toast or navigating; wiring and tests updated accordingly. > > - **MultichainAccountsConnectedList (`MultichainAccountsConnectedList.tsx`)** > - Add `isConnectionFlow` prop (default `false`). > - Update `handleSelectAccount` to early-return in connection flow (only sets `AccountTreeController.setSelectedAccountGroup`). > - Maintain existing toast + `navigation.navigate(Routes.BROWSER.HOME)` when not in connection flow; update hook deps. > - **MultichainPermissionsSummary (`MultichainPermissionsSummary.tsx`)** > - Pass `isConnectionFlow={!isAlreadyConnected}` to `MultichainAccountsConnectedList` and update memo deps. > - **Tests (`MultichainAccountsConnectedList.test.tsx`)** > - Add/adjust cases to verify: selection-only in connection flow; toast + navigation when not in connection flow. > - Explicitly set `isConnectionFlow` in relevant tests and validate correct group IDs and side effects. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 952b327. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 759b2f8 commit cc9c67a

File tree

3 files changed

+70
-10
lines changed

3 files changed

+70
-10
lines changed

app/components/Views/MultichainAccounts/MultichainAccountsConnectedList/MultichainAccountsConnectedList.test.tsx

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,10 @@ describe('MultichainAccountsConnectedList', () => {
423423
});
424424

425425
describe('handleSelectAccount functionality', () => {
426-
it('calls setSelectedAccountGroup when account is selected', () => {
427-
const { getByText } = renderMultichainAccountsConnectedList();
426+
it('calls setSelectedAccountGroup when account is selected (not in connection flow)', () => {
427+
const { getByText } = renderMultichainAccountsConnectedList({
428+
isConnectionFlow: false,
429+
});
428430

429431
const accountCell = getByText('Account 1');
430432

@@ -437,7 +439,9 @@ describe('MultichainAccountsConnectedList', () => {
437439
});
438440

439441
it('calls setSelectedAccountGroup with correct account ID for different accounts', () => {
440-
const { getByText } = renderMultichainAccountsConnectedList();
442+
const { getByText } = renderMultichainAccountsConnectedList({
443+
isConnectionFlow: false,
444+
});
441445

442446
const account1Cell = getByText('Account 1');
443447
const account2Cell = getByText('Account 2');
@@ -456,6 +460,22 @@ describe('MultichainAccountsConnectedList', () => {
456460

457461
expect(mockSetSelectedAccountGroup).toHaveBeenCalledTimes(2);
458462
});
463+
464+
it('only calls setSelectedAccountGroup when account is selected in connection flow', () => {
465+
const mockHandleEdit = jest.fn();
466+
const { getByText } = renderMultichainAccountsConnectedList({
467+
isConnectionFlow: true,
468+
handleEditAccountsButtonPress: mockHandleEdit,
469+
});
470+
471+
const accountCell = getByText('Account 1');
472+
fireEvent.press(accountCell);
473+
474+
// Should only call set selected account group instead of navigating
475+
expect(mockSetSelectedAccountGroup).toHaveBeenCalledTimes(1);
476+
expect(mockHandleEdit).not.toHaveBeenCalled();
477+
expect(mockNavigate).not.toHaveBeenCalled();
478+
});
459479
});
460480

461481
describe('Toast Functionality', () => {
@@ -465,8 +485,10 @@ describe('MultichainAccountsConnectedList', () => {
465485
mockSetSelectedAccountGroup.mockClear();
466486
});
467487

468-
it('shows toast when account is selected', () => {
469-
const { getByText } = renderMultichainAccountsConnectedList();
488+
it('shows toast when account is selected (not in connection flow)', () => {
489+
const { getByText } = renderMultichainAccountsConnectedList({
490+
isConnectionFlow: false,
491+
});
470492

471493
const accountCell = getByText('Account 1');
472494
fireEvent.press(accountCell);
@@ -487,9 +509,11 @@ describe('MultichainAccountsConnectedList', () => {
487509
});
488510
});
489511

490-
it('navigates to browser home after showing toast', () => {
491-
// Given a connected account
492-
const { getByText } = renderMultichainAccountsConnectedList();
512+
it('navigates to browser home after showing toast (not in connection flow)', () => {
513+
// Given a connected account (not in connection flow)
514+
const { getByText } = renderMultichainAccountsConnectedList({
515+
isConnectionFlow: false,
516+
});
493517

494518
// When selecting an account
495519
const accountCell = getByText('Account 1');
@@ -499,5 +523,20 @@ describe('MultichainAccountsConnectedList', () => {
499523
expect(mockNavigate).toHaveBeenCalledTimes(1);
500524
expect(mockNavigate).toHaveBeenCalledWith(Routes.BROWSER.HOME);
501525
});
526+
527+
it('does not show toast or navigate when in connection flow', () => {
528+
const mockHandleEdit = jest.fn();
529+
const { getByText } = renderMultichainAccountsConnectedList({
530+
isConnectionFlow: true,
531+
handleEditAccountsButtonPress: mockHandleEdit,
532+
});
533+
534+
const accountCell = getByText('Account 1');
535+
fireEvent.press(accountCell);
536+
537+
// Should not show toast or navigate
538+
expect(mockShowToast).not.toHaveBeenCalled();
539+
expect(mockNavigate).not.toHaveBeenCalled();
540+
});
502541
});
503542
});

app/components/Views/MultichainAccounts/MultichainAccountsConnectedList/MultichainAccountsConnectedList.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ const MultichainAccountsConnectedList = ({
3838
privacyMode,
3939
selectedAccountGroups,
4040
handleEditAccountsButtonPress,
41+
isConnectionFlow = false,
4142
}: {
4243
privacyMode: boolean;
4344
selectedAccountGroups: AccountGroupObject[];
4445
handleEditAccountsButtonPress: () => void;
46+
isConnectionFlow?: boolean;
4547
}) => {
4648
const { styles } = useStyles(styleSheet, {
4749
itemHeight: 64,
@@ -67,6 +69,12 @@ const MultichainAccountsConnectedList = ({
6769
(accountGroup: AccountGroupObject) => {
6870
const { AccountTreeController } = Engine.context;
6971
AccountTreeController.setSelectedAccountGroup(accountGroup.id);
72+
73+
// During connection flow, clicking an account should only change the selected account group instead of navigating
74+
if (isConnectionFlow) {
75+
return;
76+
}
77+
7078
const address = iconSeedAddresses[accountGroup.id];
7179
const activeAccountName = accountGroups.find(
7280
(group) => group.id === accountGroup.id,
@@ -88,7 +96,14 @@ const MultichainAccountsConnectedList = ({
8896
});
8997
navigation.navigate(Routes.BROWSER.HOME);
9098
},
91-
[navigation, iconSeedAddresses, accountAvatarType, toastRef, accountGroups],
99+
[
100+
isConnectionFlow,
101+
navigation,
102+
iconSeedAddresses,
103+
accountAvatarType,
104+
toastRef,
105+
accountGroups,
106+
],
92107
);
93108

94109
const renderItem = useCallback(

app/components/Views/MultichainAccounts/MultichainPermissionsSummary/MultichainPermissionsSummary.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,10 +524,16 @@ const MultichainPermissionsSummary = ({
524524
privacyMode={privacyMode}
525525
selectedAccountGroups={selectedAccountGroups}
526526
handleEditAccountsButtonPress={handleEditAccountsButtonPress}
527+
isConnectionFlow={!isAlreadyConnected}
527528
{...restAccountsConnectedTabProps}
528529
/>
529530
),
530-
[privacyMode, selectedAccountGroups, handleEditAccountsButtonPress],
531+
[
532+
privacyMode,
533+
selectedAccountGroups,
534+
handleEditAccountsButtonPress,
535+
isAlreadyConnected,
536+
],
531537
);
532538

533539
const renderTabsContent = () => {

0 commit comments

Comments
 (0)