From 36c0e2068a3d126eb7772ac94ff1b20c9173b5e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alexandre=20Delano=C3=AB?= <devel+git@delanoe.org>
Date: Tue, 2 Jun 2020 15:41:12 +0200
Subject: [PATCH] [FIX] NgramsTable remove existing child

---
 src/Gargantext/Components/NgramsTable.purs | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/Gargantext/Components/NgramsTable.purs b/src/Gargantext/Components/NgramsTable.purs
index 8958efb7..8c03c7ee 100644
--- a/src/Gargantext/Components/NgramsTable.purs
+++ b/src/Gargantext/Components/NgramsTable.purs
@@ -226,19 +226,27 @@ tableContainerCpt { dispatch
 
     editor = H.div {} $ maybe [] f ngramsParent
       where
-        f ngrams = [
-            H.p {} [H.text $ "Editing " <> ngramsTermText ngrams]
-          , NTC.renderNgramsTree { ngramsTable, ngrams, ngramsStyle: [], ngramsClick, ngramsEdit }
-          , H.button {className: "btn btn-primary", on: {click: (const $ dispatch AddTermChildren)}} [H.text "Save"]
-          , H.button {className: "btn btn-secondary", on: {click: (const $ dispatch $ SetParentResetChildren Nothing)}} [H.text "Cancel"]
-          ]
+        f ngrams = [ H.p {} [H.text $ "Editing " <> ngramsTermText ngrams]
+                   , NTC.renderNgramsTree { ngramsTable
+                                          , ngrams
+                                          , ngramsStyle: []
+                                          , ngramsClick
+                                          , ngramsEdit
+                                          }
+                   , H.button { className: "btn btn-primary"
+                              , on: {click: (const $ dispatch AddTermChildren)}
+                              } [H.text "Save"]
+                   , H.button { className: "btn btn-secondary"
+                              , on: {click: (const $ dispatch $ SetParentResetChildren Nothing)}
+                              } [H.text "Cancel"]
+                   ]
           where
             ngramsTable = ngramsTableCache # at ngrams
                           <<< _Just
                           <<< _NgramsElement
                           <<< _children
                           %~ applyPatchSet (patchSetFromMap ngramsChildren)
-            ngramsClick {depth: 1, ngrams: child} = Just $ dispatch $ ToggleChild true child
+            ngramsClick {depth: 1, ngrams: child} = Just $ dispatch $ ToggleChild false child
             ngramsClick _ = Nothing
             ngramsEdit  _ = Nothing
 
-- 
2.21.0