Skip to content
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

fix: Remove multiple overlapping spinners #28301

Merged
merged 3 commits into from
Nov 14, 2024
Merged

fix: Remove multiple overlapping spinners #28301

merged 3 commits into from
Nov 14, 2024

Conversation

pedronfigueiredo
Copy link
Contributor

@pedronfigueiredo pedronfigueiredo commented Nov 5, 2024

Description

We were previously using a UI blocking, whole page spinner while loading the redesigned confirmations. This overlapped with the individual component spinners we use on some components that decode transaction data. That second pattern is preferable because the spinner is contained and doesn't block the user from taking action.

The global spinner comes from routes.component. The first part of this fix is to bypass it in that file for redesigned confirmations.

The second aspect of this fix is to not condense two component spinners into one. Since the transaction flow section always loads before the send heading component, we can omit the spinner for that first component.

Finally, this PR fixes the loading behaviour on the send heading component so that if the decimals amount coming from useAssetDetails hasn't been received yet, the heading is not shown, preventing undesireable flickering in the hero value.

Open in GitHub Codespaces

Related issues

Fixes: #27972

Manual testing steps

  1. Go to test dapp
  2. Click on malicious erc20 transfer to see the 2 spinners on top and the different one in the middle
  3. Click on malicious erc20 approve to see the different spinner in the middle

Screenshots/Recordings

Before

Screenshot 2024-10-18 at 18 11 08

After

Screen.Recording.2024-11-05.at.16.45.16.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 Nov 5, 2024
@pedronfigueiredo pedronfigueiredo self-assigned this Nov 5, 2024
@pedronfigueiredo pedronfigueiredo requested review from a team as code owners November 5, 2024 17:17
Copy link
Contributor

github-actions bot commented Nov 5, 2024

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.

jpuri
jpuri previously approved these changes Nov 5, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [e48a72a]
Page Load Metrics (2100 ± 81 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint26425191925576277
domContentLoaded18102509206416479
load18502521210016881
domInteractive31285615326
backgroundConnect97528199
firstReactRender632901205828
getState971252110
initialActions01000
loadScripts13311928153714369
setupStore1298342512
uiStartup206930172366236113
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 909 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

@HowardBraham
Copy link
Contributor

@pedronfigueiredo are we going to have a direct merge conflict, or maybe even a functional merge conflict?
#28172

@pedronfigueiredo
Copy link
Contributor Author

Thanks for flagging this @HowardBraham, excited for your PR!

However, I checked out your branch and we still see the three issues my PR aims to solve:

  1. The global spinner that blocks the UI
  2. The multiple loading spinners for each component
  3. The flickering amount in the send heading component
Screen.Recording.2024-11-06.at.11.27.16.mov

So I think we need both PRs.

Comment on lines 53 to 57
decodedTransferValue: new BigNumber(
value.data[0].params[paramIndex].value.toString(),
)
.dividedBy(new BigNumber(10).pow(Number(decimals)))
.toNumber(),
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] could use calcTokenAmount here. Then, we could return toFixed to ensure precision is preserved. Then there would be no need for toNonScientificString below

Copy link
Contributor

@digiwand digiwand left a comment

Choose a reason for hiding this comment

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

It appears toNonScientificString is a newly added method in our repo as of a week ago. I think we can remove the need fo toNonScientificString by avoiding the scientific notation conversion that can be applied when JavaScript handles lengthy digits. This could be done by passing values as strings to BigNumber directly and using toFixed or toString instead of toNumber to display numbers

@metamaskbot
Copy link
Collaborator

Builds ready [63168a9]
Page Load Metrics (1772 ± 88 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint15182258177719192
domContentLoaded15062232175218388
load15152246177218388
domInteractive188044178
backgroundConnect86123178
firstReactRender482111003216
getState46613168
initialActions00000
loadScripts10891647128914469
setupStore116923188
uiStartup17962458198518790
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 56 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [f56df68]
Page Load Metrics (2227 ± 131 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint31227631951689331
domContentLoaded173927392184264127
load175428162227272131
domInteractive18199624120
backgroundConnect991452512
firstReactRender631701132010
getState583262110
initialActions01000
loadScripts12702004161619996
setupStore75914147
uiStartup196130542466278133
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 56 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@pedronfigueiredo
Copy link
Contributor Author

I addressed removing the toNonScientificNotation function as well as the precision issue mentioned #28212 on this PR

@metamaskbot
Copy link
Collaborator

Builds ready [3de0647]
Page Load Metrics (2015 ± 150 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint178233572018330159
domContentLoaded177131861991299144
load178032582015312150
domInteractive198347188
backgroundConnect97823199
firstReactRender511621122512
getState55011115
initialActions01000
loadScripts128824471465248119
setupStore65717189
uiStartup197936952238360173
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 56 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

: new Intl.NumberFormat(locale).format(decodedSpendingCap);
return isNFT || parseInt(decodedSpendingCap, 10) < 1
? decodedSpendingCap
: new Intl.NumberFormat(locale).format(parseInt(decodedSpendingCap, 10));
Copy link
Contributor

Choose a reason for hiding this comment

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

This might cause some precision issues with parseInt here. Examples of supporting precision passing BN to Intl.NumberFormat can be found here
ui/pages/confirmations/components/simulation-details/formatAmount.ts

digiwand
digiwand previously approved these changes Nov 11, 2024
Copy link
Contributor

@digiwand digiwand left a comment

Choose a reason for hiding this comment

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

nice! left one minor comment above

vinistevam
vinistevam previously approved these changes Nov 12, 2024
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Nov 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 12, 2024
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Nov 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 13, 2024
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Nov 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 13, 2024
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Nov 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 13, 2024
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Nov 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 13, 2024
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Nov 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 13, 2024
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Nov 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 13, 2024
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Nov 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 13, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [17b7015]
Page Load Metrics (1920 ± 98 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint16272435192420297
domContentLoaded16162415189320799
load16252438192020498
domInteractive1585492411
backgroundConnect871282210
firstReactRender842181113416
getState562212211
initialActions01000
loadScripts11581772139417283
setupStore67913189
uiStartup182027562165261125
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 56 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Nov 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 13, 2024
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Nov 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 13, 2024
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Nov 14, 2024
Merged via the queue into develop with commit b7c3f83 Nov 14, 2024
77 checks passed
@pedronfigueiredo pedronfigueiredo deleted the pnf/27972 branch November 14, 2024 09:26
@github-actions github-actions bot locked and limited conversation to collaborators Nov 14, 2024
@metamaskbot metamaskbot added the release-12.8.0 Issue or pull request that will be included in release 12.8.0 label Nov 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.8.0 Issue or pull request that will be included in release 12.8.0 team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Multiple overlapping spinners while loading redesigned confirmations
6 participants