From 6a6ef9b1f4a5302a687c1d0c77b58ec13e852192 Mon Sep 17 00:00:00 2001
From: Jeff Young <jeff@rokeby.ie>
Date: Fri, 30 Sep 2022 16:44:24 +0100
Subject: [PATCH] Bring adding-to-group and hiding in sync.

---
 pcbnew/tools/pcb_selection_tool.cpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp
index e6b4e1dda1..cea99f50e2 100644
--- a/pcbnew/tools/pcb_selection_tool.cpp
+++ b/pcbnew/tools/pcb_selection_tool.cpp
@@ -2574,7 +2574,10 @@ void PCB_SELECTION_TOOL::unselect( EDA_ITEM* aItem )
 void PCB_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup )
 {
     if( aGroup )
+    {
         aGroup->Add( aItem );
+        view()->Hide( aItem, true );    // Hide the original item, so it is shown only on overlay
+    }
 
     highlightInternal( aItem, aMode, aGroup != nullptr );
     view()->Update( aItem, KIGFX::REPAINT );
@@ -2593,9 +2596,6 @@ void PCB_SELECTION_TOOL::highlightInternal( EDA_ITEM* aItem, int aMode, bool aUs
     else if( aMode == BRIGHTENED )
         aItem->SetBrightened();
 
-    if( aUsingOverlay )
-        view()->Hide( aItem, true );    // Hide the original item, so it is shown only on overlay
-
     if( aItem->Type() == PCB_FOOTPRINT_T )
     {
         static_cast<FOOTPRINT*>( aItem )->RunOnChildren(
@@ -2618,7 +2618,10 @@ void PCB_SELECTION_TOOL::highlightInternal( EDA_ITEM* aItem, int aMode, bool aUs
 void PCB_SELECTION_TOOL::unhighlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup )
 {
     if( aGroup )
+    {
         aGroup->Remove( aItem );
+        view()->Hide( aItem, false );   // // Restore original item visibility
+    }
 
     unhighlightInternal( aItem, aMode, aGroup != nullptr );
     view()->Update( aItem, KIGFX::REPAINT );
@@ -2636,9 +2639,6 @@ void PCB_SELECTION_TOOL::unhighlightInternal( EDA_ITEM* aItem, int aMode, bool a
     else if( aMode == BRIGHTENED )
         aItem->ClearBrightened();
 
-    if( aUsingOverlay )
-        view()->Hide( aItem, false );   // // Restore original item visibility
-
     if( aItem->Type() == PCB_FOOTPRINT_T )
     {
         static_cast<FOOTPRINT*>( aItem )->RunOnChildren(