Skip to content

fix: prevent Buy/Sell toggle parasite animation in QuickBuy#32014

Merged
xavier-brochard merged 2 commits into
mainfrom
fix/tsa-714-buy-sell-slider-animation
Jun 18, 2026
Merged

fix: prevent Buy/Sell toggle parasite animation in QuickBuy#32014
xavier-brochard merged 2 commits into
mainfrom
fix/tsa-714-buy-sell-slider-animation

Conversation

@xavier-brochard

@xavier-brochard xavier-brochard commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

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} in QuickBuyRoot, so the toggle remounts on every subsheet round-trip (e.g. opening "Pay with" and navigating back). Meanwhile tradeMode persists in QuickBuyContext. On remount the slider's Animated.Value reset to 0 (Buy), and the layout effect unconditionally ran Animated.spring to the Sell position once onLayout fired — producing a visible "starts on Buy, flicks to Sell" animation. The text labels were already correct because they read tradeMode directly, which is why only the highlight animated.

Fix: track whether the slider has been placed once since mount (hasPositioned ref). On the first placement after layout, snap straight to the current mode with slideAnim.setValue(...); only animate via Animated.spring on subsequent tradeMode changes. 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

  1. Go to an asset details page (for a token with a sellable balance).
  2. Open QuickBuy.
  3. Switch to Sell mode.
  4. Tap the "Pay with" / "Receive" selector to open the subsheet.
  5. Navigate back to the amount screen.
  6. Verify the Buy/Sell toggle stays on Sell with no flash/parasite animation.
  7. Tapping between Buy and Sell still animates smoothly as before.

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

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>
@xavier-brochard xavier-brochard self-assigned this Jun 18, 2026
@github-actions github-actions Bot added the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label Jun 18, 2026
@mm-token-exchange-service mm-token-exchange-service Bot added the team-social-ai Social & AI team label Jun 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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.

@mm-token-exchange-service mm-token-exchange-service Bot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Jun 18, 2026
@mm-token-exchange-service

Copy link
Copy Markdown

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.

@xavier-brochard xavier-brochard marked this pull request as ready for review June 18, 2026 15:29
@xavier-brochard xavier-brochard requested a review from a team as a code owner June 18, 2026 15:29
@github-actions github-actions Bot added the risk:low AI analysis: low risk label Jun 18, 2026
@xavier-brochard xavier-brochard removed the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label Jun 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 95%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR contains only two changed files, both within the isolated SocialLeaderboard/TraderPositionView/QuickBuy component tree:

  1. QuickBuyTradeModeToggle.tsx: A targeted animation bug fix. A hasPositioned ref is added to prevent a spurious buy→sell animation when the toggle component mounts already in "sell" mode (e.g., returning from a subsheet). The fix uses slideAnim.setValue() (instant snap) instead of Animated.spring() for the first placement. This is purely a visual/animation behavior change with zero impact on business logic, state management, navigation, or user-facing functionality.

  2. QuickBuyTradeModeToggle.test.tsx: Unit tests added to cover the new snap-on-mount behavior and the subsequent animation-only-after-initial-placement behavior.

Why no E2E tags are needed:

  • The change is cosmetic (animation behavior only) — it doesn't alter any user flow, data, or navigation
  • No E2E tests reference QuickBuyTradeModeToggle directly (confirmed via grep)
  • The SocialLeaderboard feature is feature-flagged (aiSocialLeaderboardEnabled) and not covered by existing E2E smoke suites
  • No shared infrastructure (controllers, Engine, navigation, modals, confirmations) is touched
  • The fix is fully validated by the accompanying unit tests
  • No performance-sensitive code paths are affected (animation runs on JS driver, no new renders or data fetching)

Performance Test Selection:
The change is a pure animation fix (snap vs. spring on first mount) in a feature-flagged SocialLeaderboard component. It does not affect any performance-sensitive flows such as app launch, onboarding, login, asset loading, swaps, or perps. No performance test tags are warranted.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@xavier-brochard xavier-brochard added this pull request to the merge queue Jun 18, 2026
Merged via the queue into main with commit f4ac10a Jun 18, 2026
115 of 118 checks passed
@xavier-brochard xavier-brochard deleted the fix/tsa-714-buy-sell-slider-animation branch June 18, 2026 17:42
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 18, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.83.0 Issue or pull request that will be included in release 7.83.0 label Jun 18, 2026
@tommasini tommasini added release-8.0.0 Issue or pull request that will be included in release 8.0.0 and removed release-7.83.0 Issue or pull request that will be included in release 7.83.0 labels Jun 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template release-8.0.0 Issue or pull request that will be included in release 8.0.0 risk:low AI analysis: low risk size-S team-social-ai Social & AI team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants