Skip to content

Commit

Permalink
fix: fixed truncation issue for long help text (#29269)
Browse files Browse the repository at this point in the history
This PR aims to fix the truncation issue in send flow. The decimal value
in error message used to show all the decimal numbers after decimal.
This PR updates the max value to be shown after decimals to be 4 which
is also the standard decimal value we try to show in other places of
code

## **Related issues**

Fixes: #26766 

## **Manual testing steps**

1. Go to Send Flow
2. Try sending a token with large input than the available balance
3. Check the value in helptext doesn't overlap and only shows 4 numbers

## **Screenshots/Recordings**

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

### **Before**
![Screenshot 2024-12-17 at 11 17
19 AM](https://github.com/user-attachments/assets/8f9e39ba-60a6-4cd9-88f3-c7e56aa14e1c)


### **After**

![Screenshot 2024-12-17 at 11 18
05 AM](https://github.com/user-attachments/assets/08a6913e-13a1-40ad-bd48-ae8528412287)

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.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.
  • Loading branch information
NidhiKJha authored Dec 20, 2024
1 parent 7be1b0d commit 8a6f4f9
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export function AssetBalanceText({
const balanceString =
hexToDecimal(asset.balance) || tokensWithBalances[0]?.string;

const showFixedBalanceString = balanceString?.includes('.')
? balanceString.slice(0, balanceString.indexOf('.') + 5) // Include 4 digits after the decimal
: balanceString;

const balanceValue = useSelector(getSelectedAccountCachedBalance);

const nativeTokenFiatBalance = useCurrencyDisplay(balanceValue, {
Expand Down Expand Up @@ -135,7 +139,7 @@ export function AssetBalanceText({
return (
<UserPreferencedCurrencyDisplay
{...commonProps}
displayValue={`${balanceString || ''}${errorText}`}
displayValue={`${showFixedBalanceString || ''}${errorText}`}
/>
);
}
Expand Down

0 comments on commit 8a6f4f9

Please sign in to comment.