Skip to content

feat(hero-amount-input): spike Mobile per-glyph amount motion - #47648

Closed
georgewrmarshall wants to merge 5 commits into
cursor/grotzec-amount-inputs-uat-f3b4from
cursor/hero-amount-glyph-animation-fee9
Closed

georgewrmarshall wants to merge 5 commits into
cursor/grotzec-amount-inputs-uat-f3b4from
cursor/hero-amount-glyph-animation-fee9

Conversation

@georgewrmarshall

@georgewrmarshall georgewrmarshall commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

Spike for TMCU-1772 (epic TMCU-1741), following Amanda's review on #47564: sizing is approved, and she asked for Mobile's per-glyph motion. This is stacked on the UAT branch (#47557) so UAT can show the motion. It targets the Extension 13.58.0 follow-up and does not block the 13.57.0 typography work.

It ports the behavior of Mobile AnimatedNumericText, not its Reanimated code. No dependencies were added: the motion uses the Web Animations API (WAAPI) and a small layout-slide helper using the FLIP technique (measure, move, then animate the difference).

Mobile (Reanimated) Extension
Stable keys from getNumericGlyphs Same function, ported
splitNumericString Same function, ported (same test cases plus 12,, .5 and empty input)
ZoomIn.duration(120) scale(0 → 1), 120ms
ZoomOut.duration(90) A copy of the removed glyph left in place, scale(1 → 0), 90ms, then removed
LinearTransition.duration(160) FLIP translateX, 160ms, on glyphs and on the prefix and amount when a centered row re-centers
Easing.out(Easing.cubic) cubic-bezier(0.33, 1, 0.68, 1)
useReducedMotion prefers-reduced-motion through useSyncExternalStore, which turns motion off
No motion on first render Same

What changed

  • New ui/components/ui/animated-numeric-text/:
    • The splitNumericString and getNumericGlyphs helpers.
    • An AnimatedNumericText web component.
    • createFlipTracker, which records positions in em from an anchor so a font-size step is not read as movement.
    • usePrefersReducedMotion.
  • HeroAmountInput uses a ghost-input overlay:
    • The real <input> stays in place for typing, caret, selection, paste, IME and accessibility. While it has a value, its text fill is transparent.
    • The visible digits are drawn by the glyph layer underneath. This layer replaces the hidden copy of the amount that already set the field's width, so field and glyphs share one layout.
    • Kerning and ligatures are turned off on both, so the caret sits exactly between glyphs. In Storybook, the field text and the glyph layer both measured 232px for the same value.
    • The field gets an opaque selection style (primary background, inverse text), so selected digits look native.
    • The glyph layer follows the field's horizontal scroll when a long amount overflows.
    • During IME composition, and with reduced motion, the field shows its own text, the same as before this change.
  • Font-size steps: with motion on, the existing font-size transition runs at 160ms cubic-out instead of 100ms ease-out. Centered positions scale linearly with font size, so the step and the slide combine into one smooth motion. Per-frame measurements showed no overshoot (prefix moved 71 → 73.6 → 76.9 → … → 81.5).
  • The row is overflow-clip instead of overflow-hidden. Otherwise the browser scrolls the row toward the caret during the first frame of a step, while the amount is still at the larger size, causing a 15px flash. The amount wrapper now only shrinks and clips when the amount can reach the prefix, so a zooming-out glyph past the new end stays visible.
  • New stories: GlyphMotion (centered, with $) and GlyphMotionSwapField (start-aligned, 40px). Each loops through typing 12345.67 and deleting it, one keystroke every 450ms. A keypad, ⌫, Max (bulk replace) and Clear are included, and typing in the field pauses the loop.

Known gaps vs Mobile

  • The caret moves to its final position immediately, while glyphs are still sliding (Mobile has no caret).
  • Mid-string edits follow Mobile's keying: each changed digit after the edit point zooms out and back in, and separators slide. This is not specially optimized.
  • A deleted glyph zooms out from its last layout position and ignores any slide still in progress, which is a sub-pixel difference.
  • Glyphs are separate elements, so kerning between digits is off. Grotzec digits barely kern, and the same is true on Mobile.
  • AnimatedNumericText is presentational. In HeroAmountInput, the input carries the accessible name.

Changelog

CHANGELOG entry: null

Related issues

Refs: TMCU-1772

Manual testing steps

  1. Run yarn storybook and open Components/UI/HeroAmountInput → GlyphMotion.
  2. Watch the loop. Each new digit should zoom in, each deleted digit should zoom out, and $ plus the existing digits should slide as the row re-centers. This includes the step from 88px to 72px around the eighth digit.
  3. Click into the field and type, delete, use the arrow keys, select some digits, and paste (for example 42.42). The caret should sit between glyphs, selected digits should show as white on the highlight, letters and a second separator should be rejected, and paste should replace the selection.
  4. Enable "Reduce motion" in the OS and reload. The amount should update without any motion.
  5. Open GlyphMotionSwapField and repeat step 2 for the start-aligned 40px field.
  6. In the extension, open Swap/Bridge, Buy (Ramps), Perps withdraw and the custom-amount confirmation, then type and delete an amount in each.

Screenshots/Recordings

Visual validation recordings comparing against Mobile will be attached next.

Before

After

Screen.Recording.2026-11-05.at.8.06.01.AM.mov

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • 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.
Open in Web Open in Cursor 

Note

Medium Risk
User-facing amount fields (Bridge, Ramps, etc.) change rendering and layout timing while validation stays the same; regressions would show as caret/selection/IME or animation glitches rather than wrong amounts.

Reviewed by Cursor Bugbot for commit cda0664. Bugbot is set up for automated code reviews on this repo. Configure here.

cursoragent and others added 5 commits November 5, 2026 13:56
…yphs from Mobile

Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
…icText

Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
…bile

Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
@metamask-ci metamask-ci Bot added the team-design-system All issues relating to design system in Extension label Nov 5, 2026
@metamask-ci

metamask-ci Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

✨ Files requiring CODEOWNER review ✨

👨‍🔧 @MetaMask/money-movement (1 files, +96 -24)
  • 📁 ui/
    • 📁 pages/
      • 📁 ramps/
        • 📁 build-quote/
          • 📁 __snapshots__/
            • 📄 build-quote.test.tsx.snap +96 -24

🔄 @MetaMask/swaps-engineers (2 files, +74 -18)
  • 📁 ui/
    • 📁 pages/
      • 📁 bridge/
        • 📁 __snapshots__/
          • 📄 index.test.tsx.snap +26 -6
        • 📁 prepare/
          • 📁 __snapshots__/
            • 📄 prepare-bridge-page.test.tsx.snap +48 -12

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Stale FLIP positions after layout change
    • Added prefix, prefixEm, and rowWidth to the row FLIP effect deps, and skip animation after skeleton remount so layout changes refresh positions instead of leaking into the next keystroke.

Create PR

Or push these changes by commenting:

@cursor push 92597efb9e
Preview (92597efb9e)
diff --git a/ui/components/ui/hero-amount-input/hero-amount-input.tsx b/ui/components/ui/hero-amount-input/hero-amount-input.tsx
--- a/ui/components/ui/hero-amount-input/hero-amount-input.tsx
+++ b/ui/components/ui/hero-amount-input/hero-amount-input.tsx
@@ -1,4 +1,4 @@
-import React, { useLayoutEffect, useState } from 'react';
+import React, { useLayoutEffect, useRef, useState } from 'react';
 import {
   FontFamily,
   Input,
@@ -124,6 +124,9 @@
   const [isComposing, setIsComposing] = useState(false);
   const [amount, setAmount] = useState<HTMLSpanElement | null>(null);
   const [rowTracker] = useState(createFlipTracker);
+  // Set while the row is unmounted (e.g. loading skeleton) so the next play
+  // records fresh positions instead of sliding from the pre-unmount map.
+  const skipRowFlipRef = useRef(false);
   // The glyph layer draws the digits under the field, whose text is
   // transparent, so the field still draws the caret and selection. Reduced
   // motion and IME composition show the field's own text instead.
@@ -133,22 +136,37 @@
 
   // Slides the prefix and amount when a centered row re-centers, like the
   // Mobile container's LinearTransition. Positions are kept in em from the
-  // row's anchor so a font-size step is not read as movement.
+  // row's anchor so a font-size step is not read as movement. Prefix remesure,
+  // currency switches, and row resizes must also call play so the map stays
+  // current; otherwise the next keystroke animates that missed delta too.
   useLayoutEffect(() => {
     if (!row || !amount) {
+      skipRowFlipRef.current = true;
       return;
     }
     const glyphs = amount.firstElementChild ?? amount;
+    const animate = showGlyphs && !skipRowFlipRef.current;
+    skipRowFlipRef.current = false;
     rowTracker.play(
       row,
       {
         origin: align === 'center' ? row.clientWidth / 2 : 0,
         scale: getElementFontSize(glyphs),
       },
-      showGlyphs,
+      animate,
     );
     syncGlyphScroll(amount, amount.querySelector('input'));
-  }, [align, amount, row, rowTracker, showGlyphs, value]);
+  }, [
+    align,
+    amount,
+    prefix,
+    prefixEm,
+    row,
+    rowTracker,
+    rowWidth,
+    showGlyphs,
+    value,
+  ]);
 
   if (isLoading) {
     return (

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit cda0664. Configure here.

showGlyphs,
);
syncGlyphScroll(amount, amount.querySelector('input'));
}, [align, amount, row, rowTracker, showGlyphs, value]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale FLIP positions after layout change

Medium Severity

The row useLayoutEffect calls rowTracker.play only when value (or mount/align/motion) changes, so it never records a prefix remesure, currency switch, or row resize. createFlipTracker still holds the old em positions, and the next keystroke treats that delta as movement and slides prefix and amount from the wrong place.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cda0664. Configure here.

@metamask-ci

metamask-ci Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor
Builds ready [cda0664]
⚡ Performance Benchmarks (Total: 🟢 10 pass · 🟡 0 warn · 🔴 3 fail)

Baseline (latest main): f693520 | Date: 11/3/2026 | Pipeline: 42040435792 | Baseline logs

Metricschrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🔴 load_new_account(p95) [CI log]🔴 load_new_account(p95) [CI log]
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [CI log]

Regressions (🔴 3 failures)

Interaction Benchmarks · Samples: 5 🔴 2
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🔴 [CI log]
🔴 load_new_account
🔴 [CI log]
🔴 load_new_account
confirmTx
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
bridgeUserActions
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • ↑ loadNewAccount/load_new_account: +182%
  • ↑ loadNewAccount/total: +182%
  • ↓ loadNewAccount/inp: -25%
  • ↓ loadNewAccount/fcp: -23%
  • ↑ loadNewAccount/cls: +278%
  • ↑ confirmTx/longTaskTotalDuration: +13%
  • ↑ confirmTx/longTaskMaxDuration: +23%
  • ↑ confirmTx/tbt: +23%
  • ↓ confirmTx/inp: -29%
  • ↓ confirmTx/fcp: -20%
  • ↓ bridgeUserActions/bridge_load_page: -12%
  • ↑ bridgeUserActions/bridge_load_asset_picker: +52%
  • ↑ bridgeUserActions/longTaskCount: +36%
  • ↓ bridgeUserActions/longTaskMaxDuration: -31%
  • ↓ bridgeUserActions/tbt: -51%
  • ↓ bridgeUserActions/inp: -12%
  • ↓ bridgeUserActions/fcp: -24%
  • ↓ bridgeUserActions/lcp: -12%
  • ↑ bridgeUserActions/cls: +281%
  • ↑ loadNewAccount/load_new_account: +181%
  • ↑ loadNewAccount/total: +181%
  • ↓ loadNewAccount/inp: -25%
  • ↓ loadNewAccount/fcp: -38%
  • ↑ loadNewAccount/lcp: +1054%
  • ↓ confirmTx/longTaskCount: -100%
  • ↓ confirmTx/longTaskTotalDuration: -100%
  • ↓ confirmTx/longTaskMaxDuration: -100%
  • ↓ confirmTx/tbt: -100%
  • ↓ confirmTx/inp: -29%
  • ↓ confirmTx/fcp: -43%
  • ↑ confirmTx/lcp: +1045%
  • ↑ bridgeUserActions/bridge_load_page: +157%
  • ↑ bridgeUserActions/bridge_load_asset_picker: +94%
  • ↓ bridgeUserActions/longTaskCount: -100%
  • ↓ bridgeUserActions/longTaskTotalDuration: -100%
  • ↓ bridgeUserActions/longTaskMaxDuration: -100%
  • ↓ bridgeUserActions/tbt: -100%
  • ↑ bridgeUserActions/total: +31%
  • ↑ bridgeUserActions/inp: +25%
  • ↓ bridgeUserActions/fcp: -48%
  • ↑ bridgeUserActions/lcp: +1076%
Startup Benchmarks · Samples: 100
Benchmarkchrome-webpackfirefox-webpack
startupStandardHome
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • ↑ startupStandardHome/domInteractive: +10%
  • ↓ startupStandardHome/backgroundConnect: -14%
  • ↓ startupStandardHome/firstReactRender: -98%
  • ↓ startupStandardHome/initialActions: -29%
  • ↑ startupStandardHome/setupStore: +101%
  • ↓ startupStandardHome/longTaskCount: -29%
  • ↓ startupStandardHome/longTaskTotalDuration: -16%
  • ↓ startupStandardHome/longTaskMaxDuration: -13%
  • ↓ startupStandardHome/tbt: -13%
  • ↑ startupStandardHome/cls: +400%
  • ↓ startupStandardHome/uiStartup: -25%
  • ↓ startupStandardHome/load: -18%
  • ↓ startupStandardHome/domContentLoaded: -21%
  • ↓ startupStandardHome/domInteractive: -50%
  • ↓ startupStandardHome/backgroundConnect: -12%
  • ↓ startupStandardHome/firstReactRender: -99%
  • ↓ startupStandardHome/initialActions: -50%
  • ↓ startupStandardHome/loadScripts: -19%
  • ↓ startupStandardHome/setupStore: -24%
  • ↓ startupStandardHome/fcp: -36%
  • ↓ startupStandardHome/lcp: -17%
User Journey Benchmarks · Samples: 5 · mock API 🔴 1
Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [CI log]
🔴 total
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • ↑ onboardingImportWallet/srpButtonToSrpForm: +36%
  • ↑ onboardingImportWallet/confirmSrpToPwForm: +31%
  • ↑ onboardingImportWallet/pwFormToMetricsScreen: +22%
  • ↑ onboardingImportWallet/metricsToWalletReadyScreen: +31%
  • ↓ onboardingImportWallet/doneButtonToHomeScreen: -92%
  • ↓ onboardingImportWallet/openAccountMenuToAccountListLoaded: -74%
  • ↓ onboardingImportWallet/longTaskCount: -100%
  • ↓ onboardingImportWallet/longTaskTotalDuration: -100%
  • ↓ onboardingImportWallet/longTaskMaxDuration: -100%
  • ↓ onboardingImportWallet/tbt: -100%
  • ↓ onboardingImportWallet/total: -85%
  • ↑ onboardingNewWallet/srpButtonToPwForm: +44%
  • ↑ onboardingNewWallet/createPwToRecoveryScreen: +20%
  • ↑ onboardingNewWallet/skipBackupToMetricsScreen: +17%
  • ↑ onboardingNewWallet/agreeButtonToOnboardingSuccess: +13%
  • ↓ onboardingNewWallet/doneButtonToAssetList: -71%
  • ↓ onboardingNewWallet/longTaskCount: -62%
  • ↓ onboardingNewWallet/longTaskTotalDuration: -73%
  • ↓ onboardingNewWallet/longTaskMaxDuration: -36%
  • ↓ onboardingNewWallet/tbt: -94%
  • ↓ onboardingNewWallet/total: -66%
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-webpack
dappPageLoad
[Sentry log · main/release]
🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • ↓ dappPageLoad/pageLoadTime: -52%
  • ↓ dappPageLoad/firstPaint: -33%
  • ↓ dappPageLoad/firstContentfulPaint: -33%
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
Status Bundle Total Diff Change
✅ background 15.24 MiB +203 Bytes 0.00%
🚨 ui 19.35 MiB +11.21 KiB +0.06%
✅ common 0 Bytes 0 Bytes 0.00%
✅ other 4.44 MiB +73 Bytes 0.00%
✅ content scripts 3.23 MiB +146 Bytes 0.00%
🚨 unzipped 79.66 MiB +13.67 KiB +0.02%
🚨 zip 23.82 MiB +4.75 KiB +0.02%

@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2026

Copy link
Copy Markdown

@github-actions github-actions Bot locked and limited conversation to collaborators Nov 6, 2026

This branch was previously deployed

1 inactive deployment
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size-XL team-design-system All issues relating to design system in Extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants