0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 16:00:19 -05:00

🐛 Fix ungroup a component leaves asterisk in layers

This commit is contained in:
Andrés Moya 2022-02-01 13:59:32 +01:00 committed by Andrey Antukh
parent 75930a0ce9
commit 449756a0e4
3 changed files with 58 additions and 56 deletions

View file

@ -76,6 +76,7 @@
- Normalize zoom levels in workspace and viewer [Taiga #2631](https://tree.taiga.io/project/penpot/issue/2631)
- Avoid empty names in projects, files and pages [Taiga #2594](https://tree.taiga.io/project/penpot/issue/2594)
- Fix "move to" menu when duplicated team or project names [Taiga #2655](https://tree.taiga.io/project/penpot/issue/2655)
- Fix ungroup a component leaves an asterisk in layers [Taiga #2694](https://tree.taiga.io/project/penpot/issue/2694)
### :arrow_up: Deps updates

View file

@ -47,16 +47,20 @@
(update :undo-changes d/preconj del-change)))))
(defn change-parent
[changes parent-id shapes]
([changes parent-id shapes] (change-parent changes parent-id shapes nil))
([changes parent-id shapes index]
(assert (contains? (meta changes) ::objects) "Call (with-objects) first to use this function")
(let [objects (::objects (meta changes))
set-parent-change
{:type :mov-objects
(cond-> {:type :mov-objects
:parent-id parent-id
:page-id (::page-id (meta changes))
:shapes (->> shapes (mapv :id))}
(some? index)
(assoc :index index))
mk-undo-change
(fn [change-set shape]
(d/preconj
@ -69,7 +73,7 @@
(-> changes
(update :redo-changes conj set-parent-change)
(update :undo-changes #(reduce mk-undo-change % shapes)))))
(update :undo-changes #(reduce mk-undo-change % shapes))))))
(defn- generate-operation
"Given an object old and new versions and an attribute will append into changes

View file

@ -9,6 +9,7 @@
[app.common.data :as d]
[app.common.geom.shapes :as gsh]
[app.common.pages :as cp]
[app.common.pages.changes-builder :as cb]
[app.common.spec :as us]
[app.main.data.workspace.changes :as dch]
[app.main.data.workspace.common :as dwc]
@ -136,8 +137,8 @@
[group rchanges uchanges]))
(defn prepare-remove-group
[page-id group objects]
(let [shapes (into [] (:shapes group)) ; ensure we always have vector
[it page-id group objects]
(let [children (mapv #(get objects %) (:shapes group))
parent-id (cp/get-parent (:id group) objects)
parent (get objects parent-id)
@ -147,29 +148,25 @@
(filter #(#{(:id group)} (second %)))
(ffirst))
rchanges [{:type :mov-objects
:page-id page-id
:parent-id parent-id
:shapes shapes
:index index-in-parent}
{:type :del-obj
:page-id page-id
:id (:id group)}]
uchanges [{:type :add-obj
:page-id page-id
:id (:id group)
:frame-id (:frame-id group)
:obj (assoc group :shapes [])}
{:type :mov-objects
:page-id page-id
:parent-id (:id group)
:shapes shapes}
{:type :mov-objects
:page-id page-id
:parent-id parent-id
:shapes [(:id group)]
:index index-in-parent}]]
[rchanges uchanges]))
ids-to-detach (when (:component-id group)
(cp/get-children (:id group) objects))
detach-fn (fn [attrs]
(dissoc attrs
:component-id
:component-file
:component-root?
:remote-synced?
:shape-ref
:touched))]
(cond-> (-> (cb/empty-changes it page-id)
(cb/with-objects objects)
(cb/change-parent parent-id children index-in-parent)
(cb/remove-objects [(:id group)]))
(some? ids-to-detach)
(cb/update-shapes ids-to-detach detach-fn))))
(defn prepare-remove-mask
[page-id mask]
@ -223,20 +220,20 @@
objects (wsh/lookup-page-objects state page-id)
is-group? #(or (= :bool (:type %)) (= :group (:type %)))
lookup #(get objects %)
prepare #(prepare-remove-group page-id % objects)
prepare #(prepare-remove-group it page-id % objects)
changes (sequence
changes-list (sequence
(comp (map lookup)
(filter is-group?)
(map prepare))
(wsh/lookup-selected state))
rchanges (into [] (mapcat first) changes)
uchanges (into [] (mapcat second) changes)]
changes {:redo-changes (vec (mapcat :redo-changes changes-list))
:undo-changes (vec (mapcat :undo-changes changes-list))
:origin it}]
(rx/of (dch/commit-changes changes))))))
(rx/of (dch/commit-changes {:redo-changes rchanges
:undo-changes uchanges
:origin it}))))))
(def mask-group
(ptk/reify ::mask-group
ptk/WatchEvent