diff --git a/packages/react-app-revamp/components/Share/index.tsx b/packages/react-app-revamp/components/Share/index.tsx index bc9fbabe6..f37f47a5c 100644 --- a/packages/react-app-revamp/components/Share/index.tsx +++ b/packages/react-app-revamp/components/Share/index.tsx @@ -23,6 +23,11 @@ interface ShareDropdownProps { const ShareDropdown: FC = ({ contestName, contestAddress, chain, onMenuStateChange }) => { const [isCopied, setIsCopied] = useState(false); + const [isOpen, setIsOpen] = useState(false); + + useEffect(() => { + onMenuStateChange?.(isOpen); + }, [isOpen, onMenuStateChange]); useEffect(() => { if (isCopied) { @@ -42,8 +47,9 @@ const ShareDropdown: FC = ({ contestName, contestAddress, ch return ( {({ open }) => { - onMenuStateChange?.(open); - + if (open !== isOpen) { + setIsOpen(open); + } return ( <> diff --git a/packages/react-app-revamp/components/Sort/index.tsx b/packages/react-app-revamp/components/Sort/index.tsx index c5f921a8c..7eec34de7 100644 --- a/packages/react-app-revamp/components/Sort/index.tsx +++ b/packages/react-app-revamp/components/Sort/index.tsx @@ -26,6 +26,11 @@ const Sort: FC = ({ sortOptions, onSortChange, onMenuStateChange }) = const pathname = usePathname(); const router = useRouter(); const sortByFromQuery = query?.get("sortBy"); + const [isOpen, setIsOpen] = useState(false); + + useEffect(() => { + onMenuStateChange?.(isOpen); + }, [isOpen, onMenuStateChange]); useEffect(() => { if (sortByFromQuery) { @@ -79,7 +84,9 @@ const Sort: FC = ({ sortOptions, onSortChange, onMenuStateChange }) = return ( {({ open }) => { - onMenuStateChange?.(open); + if (open !== isOpen) { + setIsOpen(open); + } return ( <> diff --git a/packages/react-app-revamp/components/TokenSearchModal/components/ChainDropdown/index.tsx b/packages/react-app-revamp/components/TokenSearchModal/components/ChainDropdown/index.tsx index 4f7926a72..d893ba137 100644 --- a/packages/react-app-revamp/components/TokenSearchModal/components/ChainDropdown/index.tsx +++ b/packages/react-app-revamp/components/TokenSearchModal/components/ChainDropdown/index.tsx @@ -2,7 +2,7 @@ import { chainsImages } from "@config/wagmi"; import { Menu, MenuButton, MenuItem, MenuItems, Transition } from "@headlessui/react"; import { ChevronDownIcon } from "@heroicons/react/24/outline"; import Image from "next/image"; -import { FC, Fragment, useState } from "react"; +import { FC, Fragment, useEffect, useState } from "react"; export interface Option { value: string; @@ -25,6 +25,11 @@ const TokenSearchModalChainDropdown: FC = ({ onMenuStateChange, }) => { const [selectedOption, setSelectedOption] = useState