feat(predict): Enable Bottom Sheet via Explore page cp-7.78.0#30481
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Tag selection rationale:
The MainNavigator change is low-risk for other flows (SmokeAccounts, SmokeSwap, SmokeBrowser, etc.) since the Performance Test Selection: |
|



Description
Predict market cards on the Explore feed now open the Buy/Sell preview as an in-place bottom sheet (matching the dedicated Predict feed) when the
predictBottomSheetfeature flag is on, instead of routing to the full-page bet slip.What changed
Mounted
PredictPreviewSheetProviderat theHomeTabslevel inapp/components/Nav/Main/MainNavigator.js, wrapping theTab.Navigator. The provider was previously only mounted insidePredictScreenStack, so triggeringopenBuySheet/openSellSheetfrom any other tab fell back to navigation. Mounting atHomeTabsmakes the sheet usable from Explore (and any future tab that needs it) while keeping the existing in-Predict behavior untouched (PredictScreenStackstill mounts its own provider; the inner one shadows the outer for usage).Why mount at
HomeTabsand not inside the tab itself?BottomSheetfrom@metamask/design-system-react-nativeusesabsolute inset-0for its container. If the provider is mounted inside an individual tab's content area, the sheet's parent is smaller than the viewport and the sheet gets clipped at the top of the screen and below by the bottom tab bar. Mounting atHomeTabsputs the sheet's parent at the full-viewportHomeStack.Screen card, which is the smallest level above the tab bar that gives correct dimensions.Fixed a duplicate-toast and stale-suppression bug that the new placement exposes. With both
HomeTabsandPredictScreenStackproviders now mounted simultaneously while the user is inside the Predict stack, both used to:activeOrder.errortransitions (no dedup inToastService);_providerSheetModeCountcounter that gatesshouldSuppressLegacyOrderFailureToast(), which then swallowed the legacy failure toast in tabs/flows where the active provider could not actually fire its own toast (e.g. Wallet/Trade/Money/Rewards, or HomepageDiscoveryTabs which mounts indisableBottomSheetmode).Replaced the module-level counter with a registration stack (
_sheetModeProviders). Each entry holds the provider's id and ahasBuyParams()getter. The topmost (most recently mounted, innermost in the tree) entry is the only "active" one:PredictPreviewSheetContext.tsxbails out unless the current provider is active — so only the innermost provider fires the Retry toast.shouldSuppressLegacyOrderFailureToast()now consults the active entry'shasBuyParams(), so the legacy toast is only suppressed when the active provider will actually surface its own toast.Test coverage for the multi-provider scenario in
PredictPreviewSheetContext.test.tsx:disableBottomSheet.shouldSuppressLegacyOrderFailureToastcorrectly tracks the topmost provider across mount/unmount.Added
PredictPreviewSheetProviderto the Predict barrel (app/components/UI/Predict/index.ts) for consistency, and a rationale comment inMainNavigator.jsexplaining why the wrap lives atHomeTabs(so a future maintainer doesn't move it back inside a tab).Files touched
app/components/Nav/Main/MainNavigator.jsapp/components/Nav/Main/MainNavigator.test.tsx(mock update)app/components/UI/Predict/contexts/PredictPreviewSheetContext.tsxapp/components/UI/Predict/contexts/PredictPreviewSheetContext.test.tsxapp/components/UI/Predict/index.tsChangelog
CHANGELOG entry: Added in-place buy/sell bottom sheet to Predict market cards on the Explore feed when the
predictBottomSheetfeature flag is enabled.Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
bottomSheetExplore.mov
Pre-merge author checklist
Performance checks (if applicable)
Pre-merge reviewer checklist
Note
Medium Risk
Touches top-level navigation composition and refactors module-scoped toast suppression/dedup logic for Predict order failures; regressions could affect bottom sheet rendering or toast behavior across tabs.
Overview
Enables Predict market cards opened outside the Predict tab (e.g. Explore) to use the in-place Buy/Sell preview bottom sheet by mounting
PredictPreviewSheetProviderabove the homeTab.Navigator.Refactors
PredictPreviewSheetContextto handle multiple simultaneously-mounted providers via a registration stack: only the topmost sheet-mode provider can fire the state-driven Retry toast, and legacy order-failure toast suppression now depends on the active provider having remembered buy params (reducing stale suppression). Tests are updated/added to cover multi-provider dedup and the new suppression behavior, andPredictPreviewSheetProvideris exported from the Predict barrel.Reviewed by Cursor Bugbot for commit 51b7817. Bugbot is set up for automated code reviews on this repo. Configure here.