Skip to content

Commit fa54dae

Browse files
authored
Merge pull request #1887 from oasisprotocol/mz/tooltip
Fix multiple tooltip issue
2 parents 171e1b0 + 263afc7 commit fa54dae

6 files changed

Lines changed: 25 additions & 111 deletions

File tree

.changelog/1887.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix multiple tooltip issue

src/app/components/Blocks/BlockLink.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { FC } from 'react'
22
import { Link as RouterLink } from 'react-router-dom'
33
import Typography from '@mui/material/Typography'
44
import Link from '@mui/material/Link'
5-
65
import { RouteUtils } from '../../utils/route-utils'
7-
import { TrimLinkLabel } from '../TrimLinkLabel'
6+
import { trimLongString } from '../../utils/trimLongString'
87
import { SearchScope } from '../../../types/searchScope'
98
import { useScreenSize } from '../../hooks/useScreensize'
109
import { AdaptiveTrimmer } from '../AdaptiveTrimmer/AdaptiveTrimmer'
10+
import { MaybeWithTooltip } from '../Tooltip/MaybeWithTooltip'
1111

1212
export const BlockLink: FC<{ scope: SearchScope; height: number }> = ({ scope, height }) => (
1313
<Typography variant="mono">
@@ -30,7 +30,11 @@ export const BlockHashLink: FC<{
3030
// Table view
3131
return (
3232
<Typography variant="mono">
33-
<TrimLinkLabel label={hash} to={to} />
33+
<MaybeWithTooltip title={hash}>
34+
<Link component={RouterLink} to={to}>
35+
{trimLongString(hash)}
36+
</Link>
37+
</MaybeWithTooltip>
3438
</Typography>
3539
)
3640
}

src/app/components/Link/index.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import { FC } from 'react'
22
import { Link as RouterLink } from 'react-router-dom'
33
import { useScreenSize } from '../../hooks/useScreensize'
44
import MuiLink from '@mui/material/Link'
5-
import { TrimLinkLabel, TrimEndLinkLabel } from '../TrimLinkLabel'
65
import Typography from '@mui/material/Typography'
76
import { COLORS } from '../../../styles/theme/colors'
7+
import { trimLongString } from '../..//utils/trimLongString'
88
import { HighlightedText } from '../HighlightedText'
99
import Box from '@mui/material/Box'
1010
import { AccountMetadataSourceIndicator } from '../Account/AccountMetadataSourceIndicator'
1111
import { MaybeWithTooltip } from '../Tooltip/MaybeWithTooltip'
1212
import { WithHighlighting } from '../HighlightingContext/WithHighlighting'
13+
import { HighlightedTrimmedText } from '../HighlightedText/HighlightedTrimmedText'
1314

1415
type LinkProps = {
1516
address: string
@@ -73,9 +74,13 @@ type CustomTrimEndLinkLabelProps = {
7374
highlightedPart?: string
7475
}
7576

76-
const CustomTrimEndLinkLabel: FC<CustomTrimEndLinkLabelProps> = ({ name, to, highlightedPart }) => (
77-
<TrimEndLinkLabel label={name} to={to} trimStart={14} highlightedPart={highlightedPart} />
78-
)
77+
const CustomTrimEndLinkLabel: FC<CustomTrimEndLinkLabelProps> = ({ name, to, highlightedPart }) => {
78+
return (
79+
<MuiLink component={RouterLink} to={to}>
80+
<HighlightedTrimmedText text={name} pattern={highlightedPart} fragmentLength={14} />
81+
</MuiLink>
82+
)
83+
}
7984

8085
type TabletLinkProps = {
8186
address: string
@@ -88,7 +93,11 @@ const TabletLink: FC<TabletLinkProps> = ({ address, name, to, highlightedPart })
8893
if (name) {
8994
return <CustomTrimEndLinkLabel name={name} to={to} highlightedPart={highlightedPart} />
9095
}
91-
return <TrimLinkLabel label={address} to={to} />
96+
return (
97+
<MuiLink component={RouterLink} to={to}>
98+
{trimLongString(address)}
99+
</MuiLink>
100+
)
92101
}
93102

94103
type DesktopLinkProps = TabletLinkProps & {
@@ -102,7 +111,9 @@ const DesktopLink: FC<DesktopLinkProps> = ({ address, name, to, alwaysTrim, high
102111
{name ? (
103112
<CustomTrimEndLinkLabel name={name} to={to} highlightedPart={highlightedPart} />
104113
) : (
105-
<TrimLinkLabel label={address} to={to} />
114+
<MuiLink component={RouterLink} to={to}>
115+
{trimLongString(address)}
116+
</MuiLink>
106117
)}
107118
</WithHighlighting>
108119
)

src/app/components/TrimLinkLabel/__tests__/__snapshots__/index.test.tsx.snap

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/app/components/TrimLinkLabel/__tests__/index.test.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/app/components/TrimLinkLabel/index.tsx

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)