Commit 7b9b332c authored by Moody Salem's avatar Moody Salem

fix(popover): ios safari not showing the popover

parent 01feae97
...@@ -62,10 +62,8 @@ jobs: ...@@ -62,10 +62,8 @@ jobs:
The IPFS hash of the bundle is `${{ steps.upload.outputs.hash }}` The IPFS hash of the bundle is `${{ steps.upload.outputs.hash }}`
Uniswap uses [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) Uniswap uses [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) to store your settings.
to store your settings. **Beware** that other sites you access via the _same_ IPFS gateway can read and modify your settings on Uniswap without your permission.
**Beware** that other sites you access via the same IPFS gateway can read and modify your settings on
Uniswap without your permission.
Preferred URLs: Preferred URLs:
- [ipfs://${{ steps.upload.outputs.hash }}/](ipfs://${{ steps.upload.outputs.hash }}/) - [ipfs://${{ steps.upload.outputs.hash }}/](ipfs://${{ steps.upload.outputs.hash }}/)
......
...@@ -11,7 +11,7 @@ import { useGesture } from 'react-use-gesture' ...@@ -11,7 +11,7 @@ import { useGesture } from 'react-use-gesture'
// errors emitted, fix with https://github.com/styled-components/styled-components/pull/3006 // errors emitted, fix with https://github.com/styled-components/styled-components/pull/3006
const AnimatedDialogOverlay = animated(DialogOverlay) const AnimatedDialogOverlay = animated(DialogOverlay)
const StyledDialogOverlay = styled(AnimatedDialogOverlay)` const StyledDialogOverlay = styled(AnimatedDialogOverlay)<{ mobile: boolean }>`
&[data-reach-dialog-overlay] { &[data-reach-dialog-overlay] {
z-index: 2; z-index: 2;
display: flex; display: flex;
...@@ -95,7 +95,7 @@ interface ModalProps { ...@@ -95,7 +95,7 @@ interface ModalProps {
onDismiss: () => void onDismiss: () => void
minHeight?: number | false minHeight?: number | false
maxHeight?: number maxHeight?: number
initialFocusRef?: React.Ref<any> initialFocusRef?: React.RefObject<any>
children?: React.ReactNode children?: React.ReactNode
} }
...@@ -145,7 +145,7 @@ export default function Modal({ ...@@ -145,7 +145,7 @@ export default function Modal({
style={props} style={props}
onDismiss={onDismiss} onDismiss={onDismiss}
initialFocusRef={initialFocusRef} initialFocusRef={initialFocusRef}
mobile={isMobile} mobile={true}
> >
<Spring // animation for entrance and exit <Spring // animation for entrance and exit
from={{ from={{
...@@ -191,15 +191,9 @@ export default function Modal({ ...@@ -191,15 +191,9 @@ export default function Modal({
style={props} style={props}
onDismiss={onDismiss} onDismiss={onDismiss}
initialFocusRef={initialFocusRef} initialFocusRef={initialFocusRef}
mobile={isMobile ? isMobile : undefined} mobile={false}
> >
<StyledDialogContent <StyledDialogContent hidden={true} minHeight={minHeight} maxHeight={maxHeight} isOpen={isOpen}>
hidden={true}
minHeight={minHeight}
maxHeight={maxHeight}
isOpen={isOpen}
mobile={isMobile ? isMobile : undefined}
>
<HiddenCloseButton onClick={onDismiss} /> <HiddenCloseButton onClick={onDismiss} />
{children} {children}
</StyledDialogContent> </StyledDialogContent>
......
import { Placement } from '@popperjs/core'
import { transparentize } from 'polished' import { transparentize } from 'polished'
import React, { useState } from 'react' import React, { useState } from 'react'
import { createPortal } from 'react-dom'
import { usePopper } from 'react-popper' import { usePopper } from 'react-popper'
import styled, { keyframes } from 'styled-components' import styled, { keyframes } from 'styled-components'
import useInterval from '../../hooks/useInterval' import useInterval from '../../hooks/useInterval'
import Portal from '@reach/portal'
const fadeIn = keyframes` const fadeIn = keyframes`
from { from {
...@@ -26,7 +27,6 @@ const fadeOut = keyframes` ...@@ -26,7 +27,6 @@ const fadeOut = keyframes`
` `
const PopoverContainer = styled.div<{ show: boolean }>` const PopoverContainer = styled.div<{ show: boolean }>`
position: relative;
z-index: 9999; z-index: 9999;
visibility: ${props => (!props.show ? 'hidden' : 'visible')}; visibility: ${props => (!props.show ? 'hidden' : 'visible')};
...@@ -45,7 +45,6 @@ const ReferenceElement = styled.div` ...@@ -45,7 +45,6 @@ const ReferenceElement = styled.div`
` `
const Arrow = styled.div` const Arrow = styled.div`
position: absolute;
width: 8px; width: 8px;
height: 8px; height: 8px;
z-index: 9998; z-index: 9998;
...@@ -98,42 +97,39 @@ const Arrow = styled.div` ...@@ -98,42 +97,39 @@ const Arrow = styled.div`
export interface PopoverProps { export interface PopoverProps {
content: React.ReactNode content: React.ReactNode
showPopup: boolean show: boolean
children: React.ReactNode children: React.ReactNode
placement?: Placement
} }
export default function Popover({ content, showPopup, children }: PopoverProps) { export default function Popover({ content, show, children, placement = 'auto' }: PopoverProps) {
const [referenceElement, setReferenceElement] = useState<HTMLDivElement>(null) const [referenceElement, setReferenceElement] = useState<HTMLDivElement>(null)
const [popperElement, setPopperElement] = useState<HTMLDivElement>(null) const [popperElement, setPopperElement] = useState<HTMLDivElement>(null)
const [arrowElement, setArrowElement] = useState<HTMLDivElement>(null) const [arrowElement, setArrowElement] = useState<HTMLDivElement>(null)
const { styles, update, attributes } = usePopper(referenceElement, popperElement, { const { styles, update, attributes } = usePopper(referenceElement, popperElement, {
placement: 'auto', placement,
strategy: 'fixed', strategy: 'fixed',
modifiers: [ modifiers: [
{ name: 'offset', options: { offset: [8, 8] } }, { name: 'offset', options: { offset: [8, 8] } },
{ name: 'arrow', options: { element: arrowElement } } { name: 'arrow', options: { element: arrowElement } }
] ]
}) })
useInterval(update, show ? 100 : null)
const portal = createPortal(
<PopoverContainer show={showPopup} ref={setPopperElement} style={styles.popper} {...attributes.popper}>
{content}
<Arrow
className={`arrow-${attributes.popper?.['data-popper-placement'] ?? ''}`}
ref={setArrowElement}
style={styles.arrow}
{...attributes.arrow}
/>
</PopoverContainer>,
document.getElementById('popover-container')
)
useInterval(update, showPopup ? 100 : null)
return ( return (
<> <>
<ReferenceElement ref={setReferenceElement}>{children}</ReferenceElement> <ReferenceElement ref={setReferenceElement}>{children}</ReferenceElement>
{portal} <Portal>
<PopoverContainer show={show} ref={setPopperElement} style={styles.popper} {...attributes.popper}>
{content}
<Arrow
className={`arrow-${attributes.popper?.['data-popper-placement'] ?? ''}`}
ref={setArrowElement}
style={styles.arrow}
{...attributes.arrow}
/>
</PopoverContainer>
</Portal>
</> </>
) )
} }
import React, { useState } from 'react' import React, { useCallback, useState } from 'react'
import { HelpCircle as Question } from 'react-feather' import { HelpCircle as Question } from 'react-feather'
import styled from 'styled-components' import styled from 'styled-components'
import Tooltip from '../Tooltip' import Tooltip from '../Tooltip'
...@@ -23,22 +23,15 @@ const QuestionWrapper = styled.div` ...@@ -23,22 +23,15 @@ const QuestionWrapper = styled.div`
` `
export default function QuestionHelper({ text, disabled }: { text: string; disabled?: boolean }) { export default function QuestionHelper({ text, disabled }: { text: string; disabled?: boolean }) {
const [showPopup, setShowPopup] = useState<boolean>(false) const [show, setShow] = useState<boolean>(false)
const open = useCallback(() => setShow(true), [setShow])
const close = useCallback(() => setShow(false), [setShow])
return ( return (
<span style={{ marginLeft: 4 }}> <span style={{ marginLeft: 4 }}>
<Tooltip text={text} showPopup={showPopup && !disabled}> <Tooltip text={text} show={show && !disabled}>
<QuestionWrapper <QuestionWrapper onClick={open} onMouseEnter={open} onMouseLeave={close}>
onClick={() => {
setShowPopup(true)
}}
onMouseEnter={() => {
setShowPopup(true)
}}
onMouseLeave={() => {
setShowPopup(false)
}}
>
<Question size={16} /> <Question size={16} />
</QuestionWrapper> </QuestionWrapper>
</Tooltip> </Tooltip>
......
...@@ -18,19 +18,14 @@ export const FilterWrapper = styled(RowFixed)` ...@@ -18,19 +18,14 @@ export const FilterWrapper = styled(RowFixed)`
` `
export default function SortButton({ export default function SortButton({
title,
toggleSortOrder, toggleSortOrder,
ascending ascending
}: { }: {
title: string
toggleSortOrder: () => void toggleSortOrder: () => void
ascending: boolean ascending: boolean
}) { }) {
return ( return (
<FilterWrapper onClick={toggleSortOrder}> <FilterWrapper onClick={toggleSortOrder}>
<Text fontSize={14} fontWeight={500}>
{title}
</Text>
<Text fontSize={14} fontWeight={500}> <Text fontSize={14} fontWeight={500}>
{ascending ? '' : ''} {ascending ? '' : ''}
</Text> </Text>
......
...@@ -155,7 +155,8 @@ function SearchModal({ ...@@ -155,7 +155,8 @@ function SearchModal({
</RowBetween> </RowBetween>
<Tooltip <Tooltip
text="Import any token into your list by pasting the token address into the search field." text="Import any token into your list by pasting the token address into the search field."
showPopup={tooltipOpen} show={tooltipOpen}
placement="bottom"
> >
<SearchInput <SearchInput
type={'text'} type={'text'}
...@@ -175,11 +176,7 @@ function SearchModal({ ...@@ -175,11 +176,7 @@ function SearchModal({
{isTokenView ? 'Token Name' : 'Pool Name'} {isTokenView ? 'Token Name' : 'Pool Name'}
</Text> </Text>
{isTokenView && ( {isTokenView && (
<SortButton <SortButton ascending={invertSearchOrder} toggleSortOrder={() => setInvertSearchOrder(iso => !iso)} />
ascending={invertSearchOrder}
toggleSortOrder={() => setInvertSearchOrder(iso => !iso)}
title="Your Balances"
/>
)} )}
</RowBetween> </RowBetween>
</PaddedColumn> </PaddedColumn>
...@@ -210,7 +207,7 @@ function SearchModal({ ...@@ -210,7 +207,7 @@ function SearchModal({
<div> <div>
{isTokenView ? ( {isTokenView ? (
<Text fontWeight={500} color={theme.text2} fontSize={14}> <Text fontWeight={500} color={theme.text2} fontSize={14}>
<StyledLink onClick={openTooltip}>Having trouble importing a token?</StyledLink> <StyledLink onClick={openTooltip}>Having trouble finding a token?</StyledLink>
</Text> </Text>
) : ( ) : (
<Text fontWeight={500}> <Text fontWeight={500}>
......
...@@ -16,6 +16,7 @@ export default function useInterval(callback: () => void, delay: null | number) ...@@ -16,6 +16,7 @@ export default function useInterval(callback: () => void, delay: null | number)
} }
if (delay !== null) { if (delay !== null) {
tick()
const id = setInterval(tick, delay) const id = setInterval(tick, delay)
return () => clearInterval(id) return () => clearInterval(id)
} }
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment