From ac23c7bb4ad59bf40b500c8f1453c1f90e7658e4 Mon Sep 17 00:00:00 2001
From: "alonso.torres" <alonso.torres@kaleidos.net>
Date: Tue, 28 Mar 2023 12:18:24 +0200
Subject: [PATCH] :bug: Remove "show in view mode" flag when moving frame to
 frame

---
 CHANGES.md                                           | 1 +
 frontend/src/app/main/data/workspace.cljs            | 3 +++
 frontend/src/app/main/data/workspace/shapes.cljs     | 1 +
 frontend/src/app/main/data/workspace/transforms.cljs | 7 +++++--
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 10d5063dc..aa22feb71 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -65,6 +65,7 @@
 - Fix expanded typography on assets sidebar is moving [Taiga #5063](https://tree.taiga.io/project/penpot/issue/5063)
 - Fix spelling mistake in confirmation after importing only 1 file [Taiga #5095](https://tree.taiga.io/project/penpot/issue/5095)
 - Fix problem with selection colors and texts [Taiga #5079](https://tree.taiga.io/project/penpot/issue/5079)
+- Remove "show in view mode" flag when moving frame to frame [Taiga #5091](https://tree.taiga.io/project/penpot/issue/5091)
 
 ### :heart: Community contributions by (Thank you!)
 - To @ondrejkonec: for contributing to the code with:
diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs
index a24dd1c30..05c1d8cb3 100644
--- a/frontend/src/app/main/data/workspace.cljs
+++ b/frontend/src/app/main/data/workspace.cljs
@@ -663,6 +663,9 @@
         (cond-> (not (ctl/any-layout? objects parent-id))
           (pcb/update-shapes ordered-indexes ctl/remove-layout-item-data))
 
+        ;; Remove the hide in viewer flag
+        (pcb/update-shapes ordered-indexes #(cond-> % (cph/frame-shape? %) (assoc :hide-in-viewer true)))
+
         ;; Move the shapes
         (pcb/change-parent parent-id
                            shapes
diff --git a/frontend/src/app/main/data/workspace/shapes.cljs b/frontend/src/app/main/data/workspace/shapes.cljs
index 525fc5397..ea0f38a09 100644
--- a/frontend/src/app/main/data/workspace/shapes.cljs
+++ b/frontend/src/app/main/data/workspace/shapes.cljs
@@ -137,6 +137,7 @@
                   (pcb/with-objects objects)
                   (cond-> (not (ctl/any-layout? objects frame-id))
                     (pcb/update-shapes ordered-indexes  ctl/remove-layout-item-data))
+                  (pcb/update-shapes ordered-indexes #(cond-> % (cph/frame-shape? %) (assoc :hide-in-viewer true)))
                   (pcb/change-parent frame-id to-move-shapes 0)
                   (cond-> (ctl/grid-layout? objects frame-id)
                     (pcb/update-shapes [frame-id] ctl/assign-cells))))]
diff --git a/frontend/src/app/main/data/workspace/transforms.cljs b/frontend/src/app/main/data/workspace/transforms.cljs
index 8c4a297b5..be254bb69 100644
--- a/frontend/src/app/main/data/workspace/transforms.cljs
+++ b/frontend/src/app/main/data/workspace/transforms.cljs
@@ -104,7 +104,7 @@
 (defn start-resize
   "Enter mouse resize mode, until mouse button is released."
   [handler ids shape]
-  (letfn [(resize 
+  (letfn [(resize
            [shape initial layout [point lock? center? point-snap]]
             (let [{:keys [width height]} (:selrect shape)
                   {:keys [rotation]} shape
@@ -745,13 +745,16 @@
                  (remove (fn [shape]
                            (and (ctl/layout-absolute? shape)
                                 (= frame-id (:parent-id shape))))))
+            moving-shapes-ids
+            (map :id moving-shapes)
 
             changes
             (-> (pcb/empty-changes it page-id)
                 (pcb/with-objects objects)
                 ;; Remove layout-item properties when moving a shape outside a layout
                 (cond-> (not (ctl/any-layout? objects frame-id))
-                  (pcb/update-shapes (map :id moving-shapes) ctl/remove-layout-item-data))
+                  (pcb/update-shapes moving-shapes-ids ctl/remove-layout-item-data))
+                (pcb/update-shapes moving-shapes-ids #(cond-> % (cph/frame-shape? %) (assoc :hide-in-viewer true)))
                 (pcb/change-parent frame-id moving-shapes drop-index)
                 (pcb/remove-objects empty-parents))]