Skip to content

Commit

Permalink
fix tooltip show wrong place
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoYhun committed Aug 29, 2023
1 parent dbfd5df commit 49e1e76
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/DownloadWalletModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Trans } from '@lingui/macro'
import { rgba } from 'polished'
import { X } from 'react-feather'
import { Flex, Image, Text } from 'rebass'
import { Image, Text } from 'rebass'
import styled from 'styled-components'

import Column from 'components/Column'
Expand Down
3 changes: 2 additions & 1 deletion src/pages/TrueSightV2/components/MultipleChainDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const MultipleChainDropdown = React.forwardRef(
if (isMobile) {
return (
<Modal isOpen={show}>
<Column padding="24px" width="100%" gap="12px">
<Column padding="24px" width="100%" gap="12px" onClick={e => e.stopPropagation()}>
<Row>
<Text fontSize="20px" fontWeight={500}>
Select Chain
Expand Down Expand Up @@ -169,6 +169,7 @@ const MultipleChainDropdown = React.forwardRef(
color={theme.text}
style={{ left: menuLeft !== undefined ? `${menuLeft}px` : undefined }}
ref={ref}
onClick={e => e.stopPropagation()}
>
{tokens?.map((item: { address: string; logo: string; chain: string }) => {
if (item.chain === 'ethereum')
Expand Down
10 changes: 6 additions & 4 deletions src/pages/TrueSightV2/components/SimpleTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ export default function SimpleTooltip({
}
}, [show, x, y])

const isShow = (show || (!!x && !!y)) && !(hideOnMobile && isMobile)

const { top, left, alphaLeft } = useMemo(() => {
const clientRect = ref.current?.getBoundingClientRect()
if (!bodyRect || !clientRect || !height || !width) return {}
Expand All @@ -139,7 +141,9 @@ export default function SimpleTooltip({
}

return { top, left, alphaLeft }
}, [height, width, x, y, bodyRect])

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [height, width, x, y, bodyRect, isShow])

useEffect(() => {
if (x !== undefined && y !== undefined) {
Expand All @@ -158,15 +162,12 @@ export default function SimpleTooltip({

window.addEventListener('resize', handleResize)
window.addEventListener('scroll', handleResize)

return () => {
window.removeEventListener('resize', handleResize)
window.removeEventListener('scroll', handleResize)
}
}, [])

const isShow = (show || (!!x && !!y)) && !(hideOnMobile && isMobile)

const tooltipContent = useMemo(() => {
if (!text) return null
return ReactDOM.createPortal(
Expand All @@ -187,6 +188,7 @@ export default function SimpleTooltip({
document.body,
)
}, [alphaLeft, className, disappearOnHover, handleMouseLeave, left, maxWidthProp, text, top, widthProp])

if (disabled) {
return <>{children}</>
}
Expand Down

0 comments on commit 49e1e76

Please sign in to comment.