Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

added outside click handler

Blue Mouse0a8a532bbdea
diff --git a/package.json b/package.json
index 8e22ada88..b50387907 100644
--- a/package.json
+++ b/package.json
@@ -32,6 +32,7 @@
"react-flatpickr": "^3.10.13",
"react-helmet-async": "^1.3.0",
"react-i18next": "^12.1.1",
+ "react-outside-click-handler": "^1.3.0",
"react-qr-code": "^2.0.11",
"react-redux": "^8.0.5",
"react-router-dom": "^5.3.4",
diff --git a/src/pages/Project/View/components/LiveVisitorsDropdown.jsx b/src/pages/Project/View/components/LiveVisitorsDropdown.jsx
index a3a197809..47ae84c4d 100644
--- a/src/pages/Project/View/components/LiveVisitorsDropdown.jsx
+++ b/src/pages/Project/View/components/LiveVisitorsDropdown.jsx
@@ -1,6 +1,7 @@
import React, { useState, useEffect } from 'react'
import _map from 'lodash/map'
import { useTranslation } from 'react-i18next'
+import OutsideClickHandler from 'react-outside-click-handler'
import {
ChevronDownIcon, ChevronUpIcon, XMarkIcon,
} from '@heroicons/react/24/outline'
@@ -34,7 +35,9 @@ const LiveVisitorsDropdown = ({ live, projectId }) => {
}, [show]) // eslint-disable-line react-hooks/exhaustive-deps
return (
- <>
+ <OutsideClickHandler
+ onOutsideClick={() => setShow(false)}
+ >
<p className='h-5 mr-2 text-gray-900 dark:text-gray-50 text-xl cursor-pointer' onClick={() => setShow(!show)}>
{live}
{' '}
@@ -74,7 +77,7 @@ const LiveVisitorsDropdown = ({ live, projectId }) => {
<XMarkIcon className='absolute top-2 right-2 w-5 h-5 text-gray-900 cursor-pointer dark:text-gray-50' onClick={() => setShow(!show)} />
</div>
)}
- </>
+ </OutsideClickHandler>
)
}