Merge branch 'fix-pointer-events-bug' into 'develop'

Close dropdown-menu when component unmounts

See merge request soapbox-pub/soapbox!2284
This commit is contained in:
Chewbacca 2023-02-14 18:47:48 +00:00
commit 9b74f9264d
2 changed files with 6 additions and 1 deletions

View File

@ -64,7 +64,7 @@ const DropdownMenuItem = ({ index, item, onClick }: IDropdownMenuItem) => {
const firstItem = index === 0; const firstItem = index === 0;
if (itemRef.current && firstItem) { if (itemRef.current && firstItem) {
itemRef.current.focus(); itemRef.current.focus({ preventScroll: true });
} }
}, [itemRef.current, index]); }, [itemRef.current, index]);

View File

@ -211,6 +211,11 @@ const DropdownMenu = (props: IDropdownMenu) => {
} }
}; };
useEffect(() => {
return () => {
dispatch(closeDropdownMenu());
};
}, []);
useEffect(() => { useEffect(() => {
document.addEventListener('click', handleDocumentClick, false); document.addEventListener('click', handleDocumentClick, false);