Skip to content

Commit 75f4426

Browse files
authored
fix: cp-7.51.0 remove InteractionManager blocking account selection callbacks in certain flows (#17002)
## **Description** ### Problem The account picker was failing to select accounts in certain UI flows due to `InteractionManager.runAfterInteractions()` blocking critical selection callbacks. When the UI was busy with animations or interactions, the callback queue would be deferred indefinitely, leaving users unable to switch accounts. ### Root Cause The issue only occurred when `AccountSelector` was rendered inline within active screens (such as `BuildQuote` or `SwapsAmountView`) rather than as a modal (like the `NavBar`). In complex UI contexts with ongoing animations (keypad interactions, focus effects, loading states, etc), the interaction queue never clears, causing `runAfterInteractions()` callbacks to wait indefinitely. Works: `Navbar` → Modal `AccountSelector` (interaction queue clears on navigation) Broken: `BuildQuote`, `SwapsAmountView` inline `AccountSelector` (perpetual interaction queue from parent animations, not sure the EXACT animations causing the blockage) ### Solution Removed the `InteractionManager` wrapper around the account selection logic in `EvmAccountSelectorList` ### Impact - Account selection now works reliably across all UI states - Maintains existing functionality while fixing the blocking behavior - The `InteractionManager` was originally added for performance optimization unintentionally blocked user experience ## **Changelog** `CHANGELOG entry: null` ## **Related issues** Fixes: #16942 ## **Manual testing steps** 1. Go to this Swaps or Deposit screens 2. Constantly switch accounts and observe that account selection is no longer blocked 3. The app MAY crash when quickly switching account but that is due to another issue logged [here](#16995) ## **Screenshots/Recordings** https://github.com/user-attachments/assets/ade8ddd9-62bd-42f0-9f63-797689416655 ### **Before** NA ### **After** NA ## **Pre-merge author checklist** - [x] 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). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] 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** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] 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.
1 parent eb680d3 commit 75f4426

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

app/components/Views/AccountSelector/AccountSelector.tsx

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import React, {
77
useRef,
88
useState,
99
} from 'react';
10-
import { InteractionManager, useWindowDimensions } from 'react-native';
10+
import { useWindowDimensions } from 'react-native';
1111

1212
// External dependencies.
1313
import EvmAccountSelectorList from '../../UI/EvmAccountSelectorList';
@@ -99,21 +99,19 @@ const AccountSelector = ({ route }: AccountSelectorProps) => {
9999

100100
const _onSelectAccount = useCallback(
101101
(address: string) => {
102-
InteractionManager.runAfterInteractions(() => {
103-
Engine.setSelectedAddress(address);
104-
sheetRef.current?.onCloseBottomSheet();
105-
onSelectAccount?.(address);
106-
107-
// Track Event: "Switched Account"
108-
trackEvent(
109-
createEventBuilder(MetaMetricsEvents.SWITCHED_ACCOUNT)
110-
.addProperties({
111-
source: 'Wallet Tab',
112-
number_of_accounts: accounts?.length,
113-
})
114-
.build(),
115-
);
116-
});
102+
Engine.setSelectedAddress(address);
103+
sheetRef.current?.onCloseBottomSheet();
104+
onSelectAccount?.(address);
105+
106+
// Track Event: "Switched Account"
107+
trackEvent(
108+
createEventBuilder(MetaMetricsEvents.SWITCHED_ACCOUNT)
109+
.addProperties({
110+
source: 'Wallet Tab',
111+
number_of_accounts: accounts?.length,
112+
})
113+
.build(),
114+
);
117115
},
118116
[accounts?.length, onSelectAccount, trackEvent, createEventBuilder],
119117
);

0 commit comments

Comments
 (0)