From 3713d30353a21e370011e8667a4e7a4c04bcb471 Mon Sep 17 00:00:00 2001
From: Kirill Rogovoy <kirill@rogovoy.me>
Date: Thu, 29 Jul 2021 19:02:17 +0300
Subject: onBackgroundClick: don't cause unneccessary rerenders + reset
 hoverNode

---
 pages/index.tsx | 4 ++++
 1 file changed, 4 insertions(+)

(limited to 'pages/index.tsx')

diff --git a/pages/index.tsx b/pages/index.tsx
index 6fc83e2..d32ebc4 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -641,6 +641,10 @@ export const Graph = forwardRef(function (props: GraphProps, graphRef: any) {
       }))
     },
     onBackgroundClick: () => {
+      setHoverNode(null)
+      if (scope.nodeIds.length === 0) {
+        return 
+      }
       setScope((currentScope) => ({
         ...currentScope,
         nodeIds: [],
-- 
cgit v1.2.3

