fix: Input isn't centered in withdraw flow#41942
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. |
Builds ready [4078a94] [reused from eb8d4b6]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs
|
Add w-full to PerpsFiatHeroAmountInput container so justify-content: center correctly centers the [$][amount] row at all viewport widths, including the narrow popup. Without it the box was content-sized (~82% of parent), causing apparent left-alignment in popup mode.
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/perps (2 files, +61 -21)
|
Worker reportFix Report — TAT-2847: Input isn't centered in withdraw flowSummaryThe hero fiat amount input ( Root CauseFile: The outer Measured before fix: Changes
Test PlanAutomated:
Manual Gherkin: Evidence
TicketWorkflow Diagram (Mermaid)flowchart TD Recipe workflow diagramflowchart TD
%% Perps withdraw input centering proof
__entry__(["ENTRY"]) --> node_setup_navigate_withdraw
node_setup_navigate_withdraw["setup-navigate-withdraw<br/>ext_navigate_hash"]
node_setup_wait_withdraw_page["setup-wait-withdraw-page<br/>wait_for"]
node_ac1_click_ten_percent["ac1-click-ten-percent<br/>press"]
node_ac1_wait_non_zero_amount["ac1-wait-non-zero-amount<br/>wait_for"]
node_ac1_assert_full_width_centered["ac1-assert-full-width-centered<br/>eval_sync"]
node_ac1_screenshot_centered["ac1-screenshot-centered<br/>screenshot"]
node_teardown_navigate_home["teardown-navigate-home<br/>ext_navigate_hash"]
node_setup_navigate_withdraw --> node_setup_wait_withdraw_page
node_setup_wait_withdraw_page --> node_ac1_click_ten_percent
node_ac1_click_ten_percent --> node_ac1_wait_non_zero_amount
node_ac1_wait_non_zero_amount --> node_ac1_assert_full_width_centered
node_ac1_assert_full_width_centered --> node_ac1_screenshot_centered
node_ac1_screenshot_centered --> node_teardown_navigate_home
|
Builds ready [21ac102]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
Acknowledged @MetaMask/perps CODEOWNERS notification. Changes are limited to |
Builds ready [153f3c2]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Worker reportNo report available. |
aganglada
left a comment
There was a problem hiding this comment.
Isn't before and after looking the same?
yes I wanted to update the screenshot, the fix is working but it doesn't show because the input has a lot of decimals |
Builds ready [02101ad]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs
|
…nput Replace width: Xch with field-sizing: content so the input shrinks/grows to its actual rendered text width. The ch unit overestimates width for decimal amounts (decimal point is ~0.3ch) causing visual left-shift that w-full alone could not fix. Also replace brittle className assertions in tests with behavioral checks.
…ask/metamask-extension into fix/tat-2847-center-withdraw-input
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 a4dc701. Configure here.
Builds ready [a4dc701]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 7 warn · 🔴 1 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
field-sizing:content is not supported in Firefox. Replace with an absolute-overlay approach: a hidden clone (white-space:pre) sets the outer span's width to the exact rendered text width; the input overlays it absolutely. Absolutely-positioned children are out-of-flow so they don't affect the parent's max-content calculation, avoiding the circular dependency that caused the inline-grid approach to stretch to full width.
|
Builds ready [ed2d3b5]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|






Description
The hero amount input (
$X.XX) in the perps withdraw flow was not centered in narrow popup viewports. Two issues:Container width:
PerpsFiatHeroAmountInputwas content-sized (~82% of parent), sojustify-content: centerhad no room to center. Fixed by addingclassName="w-full"to the container box and skeleton.Input width with decimal amounts: the input used
width: Xch(ch= width of'0'). Since.is ~0.3ch wide, amounts like$270.741456appeared left-of-center even after the container fix.Fixed using an absolute-overlay pattern: a hidden clone span (same font,
white-space: pre) drives the outer span's width to the exact rendered text width; the input overlays it withposition: absolute; inset: 0. Absolutely-positioned children are out-of-flow so they don't affect the parent'smax-contentcalculation — avoiding the circular dependency that caused earlier approaches (inline-grid,field-sizing: content) to fail or be non-cross-browser.Changelog
CHANGELOG entry: null
Related issues
Fixes: TAT-2847
Manual testing steps
$X.XXamount is horizontally centered — equal left/right margins at all digit lengths, including amounts with many decimals.Screenshots/Recordings
Before
Amount was left-aligned (especially visible with decimal values like
$270.741456).After
$270)$270.741456)leftGap: 156, rightGap: 156, offset: 0leftGap: 44, rightGap: 44, offset: 0contentCenter == viewportCenter(offset = 0) at all tested lengths.Pre-merge author checklist
Pre-merge reviewer checklist