diff --git a/src/components/Layout/Sidebar/index.tsx b/src/components/Layout/Sidebar/index.tsx index b5de5f2e8..b6e44f37d 100644 --- a/src/components/Layout/Sidebar/index.tsx +++ b/src/components/Layout/Sidebar/index.tsx @@ -1,9 +1,10 @@ -import React, { ReactNode } from 'react'; +import React, { ReactNode, useRef } from 'react'; import Transition from '../../Transition'; import Link from 'next/link'; import { useRouter } from 'next/router'; import { defineMessages, FormattedMessage } from 'react-intl'; import { useUser, Permission } from '../../../hooks/useUser'; +import useClickOutside from '../../../hooks/useClickOutside'; const messages = defineMessages({ dashboard: 'Discover', @@ -116,8 +117,10 @@ const SidebarLinks: SidebarLinkProps[] = [ ]; const Sidebar: React.FC = ({ open, setClosed }) => { + const navRef = useRef(null); const router = useRouter(); const { hasPermission } = useUser(); + useClickOutside(navRef, () => setClosed()); return ( <>
@@ -166,7 +169,10 @@ const Sidebar: React.FC = ({ open, setClosed }) => {
-
+