fix: prevent Buy/Sell toggle parasite animation in QuickBuy#32014
Conversation
The QuickBuy Buy/Sell toggle remounts when navigating back from a subsheet (e.g. "Pay with") because the amount screen is keyed by activeScreen, while tradeMode persists in context. On remount the slider animated value reset to 0 (Buy) and the layout effect unconditionally sprang it to the Sell position, producing a visible parasite buy -> sell animation. Snap the slider to the current mode on its first placement after layout, and only animate on subsequent tradeMode changes. TSA-714 Co-authored-by: Cursor <cursoragent@cursor.com>
|
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. |
PR template — items to address before "Ready for review"Warnings — informational, address before merging:
See docs/readme/ready-for-review.md for the full Definition of Ready for Review. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Why no E2E tags are needed:
Performance Test Selection: |
|



Description
The QuickBuy Buy/Sell toggle (
QuickBuyTradeModeToggle) played a parasite animation when returning to the amount screen from a subsheet.Root cause: the amount screen subtree is keyed by
key={activeScreen}inQuickBuyRoot, so the toggle remounts on every subsheet round-trip (e.g. opening "Pay with" and navigating back). MeanwhiletradeModepersists inQuickBuyContext. On remount the slider'sAnimated.Valuereset to0(Buy), and the layout effect unconditionally ranAnimated.springto the Sell position onceonLayoutfired — producing a visible "starts on Buy, flicks to Sell" animation. The text labels were already correct because they readtradeModedirectly, which is why only the highlight animated.Fix: track whether the slider has been placed once since mount (
hasPositionedref). On the first placement after layout, snap straight to the current mode withslideAnim.setValue(...); only animate viaAnimated.springon subsequenttradeModechanges. This is local to the toggle — no changes to the remount/keying behavior or context, so screen transitions are unaffected.Related issues
Fixes: TSA-714
Manual testing steps
Screenshots/Recordings
Before
ScreenRecording_06-15-2026.08-41-12_1.MP4
After
Screen.Recording.2026-06-18.at.17.28.51.mov
Pre-merge author checklist
Made with Cursor