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: fix percentage change for non standard currencies #27239

Conversation

sahar-fehri
Copy link
Contributor

@sahar-fehri sahar-fehri commented Sep 18, 2024

Description

PR that fixes error when users choose a currency that is non standard currency code.

Reproduction steps:
Open the Settings > General menu
Change the Currency Conversion setting to DASH
Click outside of the extension window to close it, then reopen the extension

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Go to Settings > General menu
  2. Change the Currency Conversion setting to DASH
  3. Go back to home page; and you should not see an error

Screenshots/Recordings

Before

Screen.Recording.2024-09-18.at.10.46.17.mov

After

Screen.Recording.2024-09-18.at.10.44.00.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.

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.

@sahar-fehri sahar-fehri marked this pull request as ready for review September 18, 2024 08:47
@sahar-fehri sahar-fehri requested a review from a team as a code owner September 18, 2024 08:47
@sahar-fehri sahar-fehri requested a review from salimtb September 18, 2024 08:47
@sahar-fehri sahar-fehri added the needs-assets-ux-review A shared label between the Assets and UX team to flag PRs ready for consolidated team review. label Sep 18, 2024
Copy link

sonarcloud bot commented Sep 18, 2024

...options,
minimumFractionDigits: 2,
style: 'decimal',
}).format(balanceChange as number)} `;
Copy link
Contributor Author

@sahar-fehri sahar-fehri Sep 18, 2024

Choose a reason for hiding this comment

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

With standard currency codes, Intl.NumberFormat with currency argument would return the right currency formatted exp "$10" or "€5";

With non standard currency codes, we could do something like
`.format(balanceChange as number)} ${fiatCurrency}``; which would result in displaying the name of the currency (screenshot)

I thought it is not necessary and we can display just the value for non standard currencies;
Can update if you guys think it looks better with currency

Screenshot 2024-09-18 at 11 11 38

Copy link
Contributor

Choose a reason for hiding this comment

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

I think just the value is okay because the currency symbol is shown on the line above

@metamaskbot
Copy link
Collaborator

Builds ready [4e884c5]
Page Load Metrics (1821 ± 83 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint40021541757358172
domContentLoaded15112112179216680
load15562122182117283
domInteractive14209444120
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 138 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link
Contributor

@darkwing darkwing left a comment

Choose a reason for hiding this comment

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

The try/catch looks reasonable to me such that we aren't needing to account for what a browser would consider a valid code.

@sahar-fehri sahar-fehri merged commit c4c8fd7 into develop Sep 18, 2024
78 checks passed
@sahar-fehri sahar-fehri deleted the fix/fix-percentage-and-amount-change-for-non-standard-currencies branch September 18, 2024 15:19
@github-actions github-actions bot locked and limited conversation to collaborators Sep 18, 2024
@metamaskbot metamaskbot added the release-12.6.0 Issue or pull request that will be included in release 12.6.0 label Sep 18, 2024
@metamaskbot metamaskbot added release-12.5.0 Issue or pull request that will be included in release 12.5.0 and removed release-12.6.0 Issue or pull request that will be included in release 12.6.0 labels Sep 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs-assets-ux-review A shared label between the Assets and UX team to flag PRs ready for consolidated team review. release-12.5.0 Issue or pull request that will be included in release 12.5.0 team-assets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants