DropdownMenu: close only if open in Redux
This commit is contained in:
parent
dec2cc69e8
commit
d92a4fd239
|
@ -9,7 +9,7 @@ import {
|
||||||
openDropdownMenu,
|
openDropdownMenu,
|
||||||
} from 'soapbox/actions/dropdown-menu';
|
} from 'soapbox/actions/dropdown-menu';
|
||||||
import { closeModal, openModal } from 'soapbox/actions/modals';
|
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 { isUserTouching } from 'soapbox/is-mobile';
|
||||||
|
|
||||||
import { IconButton, Portal } from '../ui';
|
import { IconButton, Portal } from '../ui';
|
||||||
|
@ -53,6 +53,7 @@ const DropdownMenu = (props: IDropdownMenu) => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
const [isOpen, setIsOpen] = useState<boolean>(false);
|
const [isOpen, setIsOpen] = useState<boolean>(false);
|
||||||
|
const isOpenRedux = useAppSelector(state => state.dropdown_menu.isOpen);
|
||||||
|
|
||||||
const arrowRef = useRef<HTMLDivElement>(null);
|
const arrowRef = useRef<HTMLDivElement>(null);
|
||||||
const activeElement = useRef<Element | null>(null);
|
const activeElement = useRef<Element | null>(null);
|
||||||
|
@ -130,7 +131,7 @@ const DropdownMenu = (props: IDropdownMenu) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeDropdownMenu = () => {
|
const closeDropdownMenu = () => {
|
||||||
if (isOpen) {
|
if (isOpenRedux) {
|
||||||
dispatch(closeDropdownMenuRedux());
|
dispatch(closeDropdownMenuRedux());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue