DropdownMenu: close only if open in Redux

This commit is contained in:
Alex Gleason 2023-02-15 12:18:00 -06:00
parent dec2cc69e8
commit d92a4fd239
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -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<boolean>(false);
const isOpenRedux = useAppSelector(state => state.dropdown_menu.isOpen);
const arrowRef = useRef<HTMLDivElement>(null);
const activeElement = useRef<Element | null>(null);
@ -130,7 +131,7 @@ const DropdownMenu = (props: IDropdownMenu) => {
};
const closeDropdownMenu = () => {
if (isOpen) {
if (isOpenRedux) {
dispatch(closeDropdownMenuRedux());
}
};