diff --git a/src/components/SelectV2.tsx b/src/components/SelectV2.tsx index e3c80c182b..36bbab6504 100644 --- a/src/components/SelectV2.tsx +++ b/src/components/SelectV2.tsx @@ -88,6 +88,7 @@ function Select({ forceMenuPlacementTop = false, arrowColor, dropdownRender, + onHideMenu, }: { value?: string | number className?: string @@ -101,6 +102,7 @@ function Select({ onChange?: (value: any) => void forceMenuPlacementTop?: boolean arrowColor?: string + onHideMenu?: () => void // hide without changes }) { const [selected, setSelected] = useState(getOptionValue(options?.[0])) const [showMenu, setShowMenu] = useState(false) @@ -119,6 +121,7 @@ function Select({ useOnClickOutside(referenceElement as any, () => { setShowMenu(false) + onHideMenu?.() }) const selectedInfo = options.find(item => getOptionValue(item) === selected) const refMenu = useRef(null) diff --git a/src/pages/MyEarnings/MultipleChainSelectV2/index.tsx b/src/pages/MyEarnings/MultipleChainSelectV2/index.tsx index 49200680b6..6be07bb188 100644 --- a/src/pages/MyEarnings/MultipleChainSelectV2/index.tsx +++ b/src/pages/MyEarnings/MultipleChainSelectV2/index.tsx @@ -1,8 +1,8 @@ import { ChainId } from '@kyberswap/ks-sdk-core' import { Trans } from '@lingui/macro' import { rgba } from 'polished' -import { ReactNode, useEffect, useRef, useState } from 'react' -import { Box, Flex, Text } from 'rebass' +import { ReactNode, useCallback, useEffect, useRef, useState } from 'react' +import { Box, Flex } from 'rebass' import styled, { CSSProperties } from 'styled-components' import { ReactComponent as LogoKyber } from 'assets/svg/logo_kyber.svg' @@ -57,6 +57,16 @@ const ChainWrapper = styled.div` border-radius: 999px; } ` + +const Label = styled.span` + font-weight: 500; + font-size: 14px; + line-height: 20x; + color: ${({ theme }) => theme.text}; + cursor: pointer; + user-select: none; +` + const MultipleChainSelect: React.FC = ({ className, style, ...props }) => { const { comingSoonList = [], selectedChainIds = [], handleChangeChains, chainIds = [], onTracking } = props const options = chainIds.map(id => ({ value: id, label: id })) @@ -92,20 +102,26 @@ const MultipleChainSelect: React.FC = ({ className, st 0 < localSelectedChains.length && localSelectedChains.length < networkList.length }, [localSelectedChains, networkList.length]) + const onHideMenu = useCallback(() => { + setLocalSelectedChains(selectedChains) + }, [selectedChains]) + return (