Skip to content

fix: Spending cap flicker as decimals are determined #29206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 19, 2024

Conversation

pedronfigueiredo
Copy link
Contributor

@pedronfigueiredo pedronfigueiredo commented Dec 13, 2024

Description

Sometimes, when approving a token, the spending cap displayed in the transaction simulation component flickers for a split second. This can also seen when editing the spending cap on the same screen.

In the approve screen, useAssetDetails returns decimals at first as undefined while it's determined asynchronously. Since useApproveTokenSimulation takes decimals as an argument, a default of '0' was set to quiet the type-checker. This default is what provokes the UI flicker.

In the example video below, the token has 4 decimals and the spending cap is 70000 / 10 ** 4 = 7. But while decimals is still undefined, '0' is used in useApproveTokenSimulation to determine the spending cap (dividing the value by 10 to the number of decimals). This amounts to 70000 instead of 7 for a split second, before decimals '4' is returned by useAssetDetails.

The fix for this bug is to let the loading spinner linger a few miliseconds longer while decimals is still undefined.

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

before.the.bug.happens.mov

After

after.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.

@pedronfigueiredo pedronfigueiredo added the team-confirmations Push issues to confirmations team label Dec 13, 2024
@pedronfigueiredo pedronfigueiredo self-assigned this Dec 13, 2024
@pedronfigueiredo pedronfigueiredo requested a review from a team as a code owner December 13, 2024 19:00
Copy link
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.

@pedronfigueiredo pedronfigueiredo force-pushed the pnf/fix-spending-cap-flicker branch 3 times, most recently from bfa15d5 to be646b7 Compare December 16, 2024 17:31
@metamaskbot
Copy link
Collaborator

Builds ready [be646b7]
Page Load Metrics (1872 ± 55 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint33020801569601289
domContentLoaded15252093183912359
load15882100187211455
domInteractive257844168
backgroundConnect974352311
firstReactRender1689392311
getState56216136
initialActions01000
loadScripts11061599138611153
setupStore763252210
uiStartup18372390212913163
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 8 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@jpuri
Copy link
Contributor

jpuri commented Dec 17, 2024

Hey @pedronfigueiredo : default of 0 passed to useApproveTokenSimulation does not sounds like good idea, can we rather change it to take undefined ?

@pedronfigueiredo pedronfigueiredo force-pushed the pnf/fix-spending-cap-flicker branch 2 times, most recently from 96edeca to 9e5f513 Compare December 17, 2024 13:10
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/fix-spending-cap-flicker branch from 9e5f513 to e51dcb4 Compare December 17, 2024 14:25
@metamaskbot
Copy link
Collaborator

Builds ready [e51dcb4]
Page Load Metrics (1648 ± 82 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint14552278165217785
domContentLoaded14112204161917282
load14582247164817282
domInteractive2489422110
backgroundConnect115525167
firstReactRender1587352512
getState576192010
initialActions01000
loadScripts10461706122214871
setupStore65516168
uiStartup163925931902220106
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: -16 Bytes (-0.00%)
  • common: 0 Bytes (0.00%)

@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Dec 19, 2024
Merged via the queue into main with commit 749d0ac Dec 19, 2024
77 checks passed
@pedronfigueiredo pedronfigueiredo deleted the pnf/fix-spending-cap-flicker branch December 19, 2024 11:35
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2024
@metamaskbot metamaskbot added the release-12.11.0 Issue or pull request that will be included in release 12.11.0 label Dec 19, 2024
@ZbrancaI
Copy link

ZbrancaI commented Jan 29, 2025

Hey @pedronfigueiredo! I just tested this on the Chrome build for 12.11.0, and the issue still seems to occur.

Screen.Recording.2025-01-29.at.9.32.14.PM.mov

@ZbrancaI
Copy link

Hey @pedronfigueiredo! I just tested this on the Chrome build for 12.11.0, and the issue still seems to occur.

Screen.Recording.2025-01-29.at.9.32.14.PM.mov

The issue is solved on the latest build

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.11.0 Issue or pull request that will be included in release 12.11.0 team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants