📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
don't trigger exit intent popup on context menu open
Blue Mouse740d17d50428
diff --git a/web/app/components/ExitIntentPopup.tsx b/web/app/components/ExitIntentPopup.tsxindex 40e9b9ddc..890fd780a 100644--- a/web/app/components/ExitIntentPopup.tsx+++ b/web/app/components/ExitIntentPopup.tsx@@ -1,5 +1,5 @@import { XIcon } from 'lucide-react'-import { useEffect, useState } from 'react'+import { useEffect, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'import { Link } from 'react-router'@@ -18,6 +18,8 @@ export default function ExitIntentPopup({ isStandalone = false }: ExitIntentPopuconst { t } = useTranslation('common')const [isVisible, setIsVisible] = useState(false)const [isDismissed, setIsDismissed] = useState(false)+ const contextMenuActiveRef = useRef(false)+ const contextMenuTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)useEffect(() => {if (isStandalone) {@@ -33,16 +35,36 @@ export default function ExitIntentPopup({ isStandalone = false }: ExitIntentPopulet hasTriggered = falseconst handleMouseLeave = (e: MouseEvent) => {+ if (contextMenuActiveRef.current) {+ return+ }if (!e.relatedTarget && !hasTriggered && !isDismissed) {hasTriggered = truesetIsVisible(true)}}+ const handleContextMenu = () => {+ contextMenuActiveRef.current = true+ if (contextMenuTimeoutRef.current) {+ clearTimeout(contextMenuTimeoutRef.current)+ }+ contextMenuTimeoutRef.current = setTimeout(() => {+ contextMenuActiveRef.current = false+ contextMenuTimeoutRef.current = null+ }, 1500)+ }+document.addEventListener('mouseout', handleMouseLeave)+ document.addEventListener('contextmenu', handleContextMenu)return () => {document.removeEventListener('mouseout', handleMouseLeave)+ document.removeEventListener('contextmenu', handleContextMenu)+ if (contextMenuTimeoutRef.current) {+ clearTimeout(contextMenuTimeoutRef.current)+ contextMenuTimeoutRef.current = null+ }}}, [isStandalone, isDismissed])