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 changes when balance is zero #25550

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

salimtb
Copy link
Contributor

@salimtb salimtb commented Jun 27, 2024

Description

This PR addresses a UI inconsistency observed in the account balance display, particularly when the account balance is at 0.00. Users have reported confusion over the display of a non-zero percentage change next to a +0.00 change in account value. This scenario occurs when there is no balance (neither in ETH nor in the selected fiat currency, USD in this case) in the user's account. The expectation is that if the account has not increased or decreased in value (due to having no balance), the displayed percentage change should also reflect a 0% change, aligning with the +$0.00 change displayed.

Problem: When the account balance is zero, the UI currently shows a +$0.00 change (as expected) but accompanies this with a non-zero percentage change (e.g., -1.74%), which is misleading and confusing to users. This discrepancy occurs despite the account's value not actually changing, given the lack of funds.

Solution: The proposed solution involves adjusting the logic that calculates and displays the percentage change in account value. Specifically, when the account balance is $0.00, the percentage change should also display as +0.00%, reflecting the true state of the account's value change (or lack thereof). This change ensures consistency in the UI and improves user understanding of their account's status.

Implementation Details:

Modify the calculation function to check for a $0.00 account balance condition. Upon detecting this condition, the function will automatically set the percentage change value to +0.00%.
Update the UI component responsible for displaying the percentage change to correctly render the +0.00% value when the account balance is zero.
Add unit tests to cover this scenario, ensuring that the percentage change correctly reflects a 0% change when the account balance is $0.00.
Expected Outcome: With this fix, users with a 0.00 account balance will see both a +0.00 change and a +0.00% change, eliminating confusion and providing a clearer understanding of their account's status. This update aims to enhance the user experience by ensuring consistency and clarity in the display of account value changes.

Open in GitHub Codespaces

Related issues

Fixes: #25539

Manual testing steps

  1. Go to the wallet page
  2. Select account with 0 native token balance

Screenshots/Recordings

Before

Screenshot 2024-06-27 at 11 41 18

After

Screenshot 2024-06-27 at 11 41 39

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.

@salimtb salimtb requested a review from a team as a code owner June 27, 2024 09:42
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.

@salimtb salimtb added team-assets needs-assets-ux-review A shared label between the Assets and UX team to flag PRs ready for consolidated team review. labels Jun 27, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [72753de]
Page Load Metrics (136 ± 185 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint6210780115
domContentLoaded8131011
load401817136386185
domInteractive8131011
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 8 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link

codecov bot commented Jun 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.67%. Comparing base (6918c52) to head (72753de).
Report is 3 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #25550   +/-   ##
========================================
  Coverage    69.67%   69.67%           
========================================
  Files         1349     1349           
  Lines        47850    47850           
  Branches     13195    13196    +1     
========================================
  Hits         33337    33337           
  Misses       14513    14513           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Makes sense.

@salimtb salimtb merged commit 09b2392 into develop Jun 27, 2024
83 of 84 checks passed
@salimtb salimtb deleted the fix-percentage-for-zero-balance branch June 27, 2024 15:05
@github-actions github-actions bot locked and limited conversation to collaborators Jun 27, 2024
@metamaskbot metamaskbot added the release-12.1.0 Issue or pull request that will be included in release 12.1.0 label Jun 27, 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.1.0 Issue or pull request that will be included in release 12.1.0 team-assets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A confusing non-zero percentage appears underneath zero balance
4 participants