Repository navigation
feat(hero-amount-input): spike Mobile per-glyph amount motion - #47648
georgewrmarshall wants to merge 5 commits into
Conversation
…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>
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/money-movement (1 files, +96 -24)
🔄 @MetaMask/swaps-engineers (2 files, +74 -18)
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
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.
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]); |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit cda0664. Configure here.
Builds ready [cda0664]
⚡ Performance Benchmarks (Total: 🟢 10 pass · 🟡 0 warn · 🔴 3 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
|






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).getNumericGlyphssplitNumericString12,,.5and empty input)ZoomIn.duration(120)scale(0 → 1), 120msZoomOut.duration(90)scale(1 → 0), 90ms, then removedLinearTransition.duration(160)translateX, 160ms, on glyphs and on the prefix and amount when a centered row re-centersEasing.out(Easing.cubic)cubic-bezier(0.33, 1, 0.68, 1)useReducedMotionprefers-reduced-motionthroughuseSyncExternalStore, which turns motion offWhat changed
ui/components/ui/animated-numeric-text/:splitNumericStringandgetNumericGlyphshelpers.AnimatedNumericTextweb component.createFlipTracker, which records positions in em from an anchor so a font-size step is not read as movement.usePrefersReducedMotion.HeroAmountInputuses a ghost-input overlay:<input>stays in place for typing, caret, selection, paste, IME and accessibility. While it has a value, its text fill is transparent.overflow-clipinstead ofoverflow-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.GlyphMotion(centered, with$) andGlyphMotionSwapField(start-aligned, 40px). Each loops through typing12345.67and deleting it, one keystroke every 450ms. A keypad,⌫,Max(bulk replace) andClearare included, and typing in the field pauses the loop.Known gaps vs Mobile
AnimatedNumericTextis presentational. InHeroAmountInput, the input carries the accessible name.Changelog
CHANGELOG entry: null
Related issues
Refs: TMCU-1772
Manual testing steps
yarn storybookand open Components/UI/HeroAmountInput → GlyphMotion.$plus the existing digits should slide as the row re-centers. This includes the step from 88px to 72px around the eighth digit.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.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
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.