diff --git a/libs/shared/lib/querybuilder/panel/ContextMenu.tsx b/libs/shared/lib/querybuilder/panel/ContextMenu.tsx
index f13fb451a2bb0b8fb3ed54369304baac6291a3ce..283b18e2b50b337503320ed33617f37f976cd0e0 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();