From 36b11ad3c601ff34645ffedfaa25d815fe770221 Mon Sep 17 00:00:00 2001
From: Sjoerd <svink@graphpolaris.com>
Date: Tue, 5 Nov 2024 08:43:25 +0000
Subject: [PATCH] fix: remove logic pill on node removal in qb

---
 libs/shared/lib/querybuilder/panel/ContextMenu.tsx | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libs/shared/lib/querybuilder/panel/ContextMenu.tsx b/libs/shared/lib/querybuilder/panel/ContextMenu.tsx
index f13fb451a..283b18e2b 100644
--- a/libs/shared/lib/querybuilder/panel/ContextMenu.tsx
+++ b/libs/shared/lib/querybuilder/panel/ContextMenu.tsx
@@ -76,6 +76,14 @@ export const ContextMenu = (props: {
   }
   function removeNode() {
     if (!props.node) return;
+    const connectedLogicPills = graphologyGraph.neighbors(props.node.id);
+    connectedLogicPills.forEach((pill) => {
+      const attributes = graphologyGraph.getNodeAttributes(pill);
+      if (attributes.type === 'logic') {
+        graphologyGraph.dropNode(pill);
+      }
+    });
+
     graphologyGraph.dropNode(props.node.id);
     dispatch(setQuerybuilderGraphology(graphologyGraph));
     props.onClose();
-- 
GitLab