feat(predict): Bottom Sheet Keyboard Fix cp-7.78.0#30483
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 85e0591. Configure here.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Risk: Medium - these are UI behavior changes to the Predictions buy flow that could affect how the keypad opens/closes and when bottom content (fee summary, action button) is visible. The refactoring touches the core interaction model of the buy flow. Tag rationale:
Performance Test Selection: |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #30483 +/- ##
==========================================
- Coverage 82.14% 82.14% -0.01%
==========================================
Files 5478 5478
Lines 147361 147362 +1
Branches 33883 33882 -1
==========================================
- Hits 121054 121051 -3
- Misses 18015 18018 +3
- Partials 8292 8293 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|




Description
The Predict Buy bottom-sheet introduced in #28779 opened with the custom keypad already rendered behind the rest of the sheet content. The root cause was a single
isInputFocusedboolean insideusePredictBuyInputStatethat was hard-coded totrueon first render and overloaded across five unrelated behaviours:PredictKeypad.PredictBuyBottomContentwhile the keypad is up.PredictFeeSummary.updatePendingAmount/setPayToken) insidePredictPayWithAnyTokenInfo.Because the only "off switch" was
setIsInputFocused(false)(driven from aDonebutton that doesn't exist in sheet mode) the previous PR worked around the issue with threeisSheetMode ? false : isInputFocusedternaries — Bugbot flagged this on #28779. The workarounds also produced a confusing situation where bottom content and keypad rendered simultaneously on first sheet open.This PR separates the conflated meanings, parameterises the initial state, and removes the workarounds. No behaviour change for the legacy full-screen flow.
What changed
usePredictBuyInputState(hooks/usePredictBuyInputState.ts){ initialKeypadOpen = true }.isInputFocused→isKeypadOpen,setIsInputFocused→setIsKeypadOpen.PredictBuyWithAnyToken(PredictBuyWithAnyToken.tsx)usePredictBuyInputState({ initialKeypadOpen: !isSheetMode })so the sheet opens with the keypad collapsed.isSheetMode ? false : isInputFocusedpatches.PredictBuyBottomContentat the call site via{(isSheetMode || !isKeypadOpen) && <PredictBuyBottomContent ... />}instead of relying on the component to bail internally. Keeps the legacy "hide while typing" behaviour while letting the sheet show the bottom content (and Confirm) at all times.shouldDeferRelaySetup={!isSheetMode && isKeypadOpen}prop toPredictPayWithAnyTokenInfo. Same effective value as before, but the prop name now describes its actual purpose.PredictPayWithAnyTokenInfo(components/PredictPayWithAnyTokenInfo)isInputFocused→shouldDeferRelaySetup. This is the genuine separation: the prop is not about UI keypad state, it's about pausingupdatePendingAmount/setPayTokencalls. Legacy mode still defers until the user taps Done; sheet mode never defers (relay must update on every keystroke since there's no Done and the user can tap Confirm with the keypad still open — preventing underfunded deposits).PredictBuyBottomContent(components/PredictBuyBottomContent)isInputFocusedprop and theif (isInputFocused) return nullearly return. Component is now purely structural; visibility is the parent's responsibility.PredictKeypadandPredictBuyAmountSectionisInputFocused→isKeypadOpen,setIsInputFocused→setIsKeypadOpen.Legacy
PredictBuyPreview(views/PredictBuyPreview)useState(true)renamed toisKeypadOpenfor consistency with the rest of the tree. No behaviour change (still initialisestrue, still gatesrenderBottomContent).Tests
usePredictBuyInputStateforinitialKeypadOpen: falseandinitialKeypadOpen: true.PredictBuyWithAnyToken.test.tsxthat the hook is called withinitialKeypadOpen: falsein sheet mode andinitialKeypadOpen: truein non-sheet mode.PredictBuyBottomContent.test.tsx: removed the now-irrelevantisInputFocused is true / falsedescribe blocks since visibility is caller-controlled.PredictPayWithAnyTokenInfo.test.tsx: updated 43 prop references and renamed two test descriptions to reflect the new "relay deferral" intent.PredictBuyPreview.test.tsx: updatedrenderBottomContentdescribe block descriptions.Net behavioural effect (sheet mode)
$0(inactive), quick amounts + pay-with row + fee summary + Confirm button visible (Confirm disabled until amount > 0).shouldDeferRelaySetupisfalsein sheet mode).Legacy full-screen flow: unchanged.
Changelog
CHANGELOG entry: null
Related issues
Refs: PRED-707 (follow-up to #28779)
Manual testing steps
Screenshots/Recordings
Before
Sheet opens with the keypad rendered behind the bottom content; bottom content and keypad are both visible simultaneously on first paint. (See screenshot in PR comments — keypad sits below
Confirmeven though the user has not yet tapped the amount display.)After
Sheet opens with the keypad hidden; bottom content (quick amounts, pay with row, fee summary, Confirm) is the only thing visible. Tapping the amount display reveals the keypad; tapping a quick amount or Confirm collapses it.
bottomSheetKeyboardFix.mov
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an examplePre-merge reviewer checklist
Note
Medium Risk
Changes how the Predict buy keypad state is tracked and used to gate bottom content and mm_pay relay setup; mistakes could surface as incorrect UI visibility or misconfigured deposit/payment amounts during checkout. Scope is mostly contained to Predict buy views and covered by updated tests.
Overview
Fixes the Predict buy bottom-sheet keypad initial state by splitting the previously overloaded
isInputFocusedflag into a dedicatedisKeypadOpenstate, including a newinitialKeypadOpenoption inusePredictBuyInputStateso sheet mode can start closed.Updates
PredictBuyWithAnyToken/PredictKeypad/PredictBuyAmountSectionto useisKeypadOpenfor keypad mounting and active styling, moves bottom-content visibility control to the parent (removingPredictBuyBottomContent’s internal early-return), and introducesshouldDeferRelaySetup(replacingisInputFocused) to explicitly gatePredictPayWithAnyTokenInfo’s relay-configuration side effects.Refactors legacy
PredictBuyPreviewto the sameisKeypadOpennaming and updates/adds tests to assert the new initialization, visibility behavior, and relay deferral propagation.Reviewed by Cursor Bugbot for commit 98d3d4d. Bugbot is set up for automated code reviews on this repo. Configure here.