Skip to content

Commit 5399a35

Browse files
Dhanraj30LuizAsFighthelciofranco
authored
fix: long recipient name breaking line on Account (#1760)
Fix Long Recipent name and undo formating ref : #1756 , #1752 before changes: ![Screenshot (170)](https://github.com/user-attachments/assets/6950ca8c-1dbc-49dc-a6d6-d9151ee74eb5) after chnages the output ![Screenshot 2025-01-07 143708](https://github.com/user-attachments/assets/8730e718-5d47-43da-b7e7-e9f320237883) --------- Co-authored-by: Luiz Gomes <8636507+LuizAsFight@users.noreply.github.com> Co-authored-by: Hélcio Franco <github@helciofranco.com>
1 parent 8aa814f commit 5399a35

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

.changeset/old-jars-battle.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"fuels-wallet": patch
3+
---
4+
5+
Fixing display of long recipient names

packages/app/src/systems/Transaction/components/TxRecipientCard/TxRecipientCard.tsx

+43-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
import { cssObj } from '@fuel-ui/css';
2-
import { Avatar, Box, Card, Heading, Icon, Image, Text } from '@fuel-ui/react';
2+
import {
3+
Avatar,
4+
Box,
5+
Card,
6+
Heading,
7+
Icon,
8+
Image,
9+
Text,
10+
Tooltip,
11+
} from '@fuel-ui/react';
312
import type { OperationTransactionAddress } from 'fuels';
413
import { Address, AddressType, ChainName, isB256, isBech32 } from 'fuels';
5-
import { type FC, useMemo } from 'react';
14+
import { type FC, useEffect, useMemo, useRef, useState } from 'react';
615
import { EthAddress, FuelAddress, useAccounts } from '~/systems/Account';
716

817
import { useContractMetadata } from '~/systems/Contract/hooks/useContractMetadata';
@@ -33,6 +42,8 @@ export const TxRecipientCard: TxRecipientCardComponent = ({
3342
const isNetwork = address === 'Network';
3443

3544
const contract = useContractMetadata(address);
45+
const nameRef = useRef<HTMLHeadingElement>(null);
46+
const [isTruncated, setIsTruncated] = useState(false);
3647

3748
const name = useMemo<string>(() => {
3849
if (isContract) {
@@ -42,6 +53,23 @@ export const TxRecipientCard: TxRecipientCardComponent = ({
4253
return accounts?.find((a) => a.address === fuelAddress)?.name || 'unknown';
4354
}, [isContract, contract, accounts, fuelAddress]);
4455

56+
useEffect(() => {
57+
const checkIfTruncated = () => {
58+
if (nameRef.current) {
59+
const isNameTruncated =
60+
nameRef.current.offsetWidth < nameRef.current.scrollWidth;
61+
setIsTruncated(isNameTruncated);
62+
}
63+
};
64+
65+
checkIfTruncated();
66+
window.addEventListener('resize', checkIfTruncated);
67+
68+
return () => {
69+
window.removeEventListener('resize', checkIfTruncated);
70+
};
71+
}, [name]);
72+
4573
return (
4674
<Card
4775
css={styles.root}
@@ -97,7 +125,19 @@ export const TxRecipientCard: TxRecipientCardComponent = ({
97125
isNetwork ? 'Address' : 'Name'
98126
}`}
99127
>
100-
{isNetwork ? address : name}
128+
<Tooltip content={name} open={isTruncated ? undefined : false}>
129+
<div
130+
ref={nameRef}
131+
style={{
132+
textOverflow: 'ellipsis',
133+
whiteSpace: 'nowrap',
134+
overflow: 'hidden',
135+
maxWidth: '100px',
136+
}}
137+
>
138+
{name}
139+
</div>
140+
</Tooltip>
101141
</Heading>
102142
{!isNetwork && (
103143
<FuelAddress

0 commit comments

Comments
 (0)