From d92a4fd239f8ddcb99236b2a8ed8b5a502d6f8e0 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 15 Feb 2023 12:18:00 -0600 Subject: [PATCH] DropdownMenu: close only if open in Redux --- app/soapbox/components/dropdown-menu/dropdown-menu.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/soapbox/components/dropdown-menu/dropdown-menu.tsx b/app/soapbox/components/dropdown-menu/dropdown-menu.tsx index 4d7c400af..f4d885b7f 100644 --- a/app/soapbox/components/dropdown-menu/dropdown-menu.tsx +++ b/app/soapbox/components/dropdown-menu/dropdown-menu.tsx @@ -9,7 +9,7 @@ import { openDropdownMenu, } from 'soapbox/actions/dropdown-menu'; import { closeModal, openModal } from 'soapbox/actions/modals'; -import { useAppDispatch } from 'soapbox/hooks'; +import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import { isUserTouching } from 'soapbox/is-mobile'; import { IconButton, Portal } from '../ui'; @@ -53,6 +53,7 @@ const DropdownMenu = (props: IDropdownMenu) => { const history = useHistory(); const [isOpen, setIsOpen] = useState(false); + const isOpenRedux = useAppSelector(state => state.dropdown_menu.isOpen); const arrowRef = useRef(null); const activeElement = useRef(null); @@ -130,7 +131,7 @@ const DropdownMenu = (props: IDropdownMenu) => { }; const closeDropdownMenu = () => { - if (isOpen) { + if (isOpenRedux) { dispatch(closeDropdownMenuRedux()); } };