Skip to content

A confusing non-zero percentage appears underneath zero balance #25539

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

Closed
9 tasks
mcmire opened this issue Jun 26, 2024 · 0 comments · Fixed by #25550
Closed
9 tasks

A confusing non-zero percentage appears underneath zero balance #25539

mcmire opened this issue Jun 26, 2024 · 0 comments · Fixed by #25550
Assignees
Labels
release-12.1.0 Issue or pull request that will be included in release 12.1.0

Comments

@mcmire
Copy link
Contributor

mcmire commented Jun 26, 2024

What is this about?

When I have no balance in my account, then I see that I have no ETH and nothing in whatever fiat currency I've chosen (USD in my case). That is all well and good, but then I also see +$0.00 with a non-zero percentage next to it. The +$0.00 makes sense. If I did have money in my account, I would expect this to be the difference in USD that my account has increased today based on the current spot price of USD/ETH, or something like that — but I don't have anything, so my account has neither increased or decreased in value. However, the non-zero percentage is a bit confusing. I would expect this to be connected to +$0.00, and so it should be +0.00% as well. However, perhaps there is a better solution to this which prevents us from needing to show the percentage at all.

(Notice the -1.74% in the screenshot below)

Screenshot 2024-06-26 at 9 28 03 AM

Scenario

No response

Design

No response

Technical Details

No response

Threat Modeling Framework

No response

Acceptance Criteria

No response

Stakeholder review needed before the work gets merged

  • Engineering (needed in most cases)
  • Design
  • Product
  • QA (automation tests are required to pass before merging PRs but not all changes are covered by automation tests - please review if QA is needed beyond automation tests)
  • Security
  • Legal
  • Marketing
  • Management (please specify)
  • Other (please specify)

References

No response

@salimtb salimtb self-assigned this Jun 27, 2024
salimtb added a commit that referenced this issue Jun 27, 2024
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **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](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/25550?quickstart=1)

## **Related issues**

Fixes: #25539 

## **Manual testing steps**

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

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->
<img width="803" alt="Screenshot 2024-06-27 at 11 41 18"
src="https://github.com/MetaMask/metamask-extension/assets/26223211/8ea3c9ec-fba7-4d04-b209-b50383a01e08">

### **After**

<!-- [screenshots/recordings] -->
<img width="1079" alt="Screenshot 2024-06-27 at 11 41 39"
src="https://github.com/MetaMask/metamask-extension/assets/26223211/5d2d71cb-7086-4338-bc32-4eaeb67e69e8">


## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.
@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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-12.1.0 Issue or pull request that will be included in release 12.1.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants