diff --git a/CHANGES.md b/CHANGES.md index 515d3505fa..f88f801f5b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -28,6 +28,7 @@ - Fix problem with pan and space [#811](https://github.com/penpot/penpot/issues/811) - Fix issue when parsing exponential numbers in paths - Remove legacy system user and team [#843](https://github.com/penpot/penpot/issues/843) +- Fix ordering of copy pasted objects [Taiga #1618](https://tree.taiga.io/project/penpot/issue/1617) - Fix problems with blending modes [#837](https://github.com/penpot/penpot/issues/837) - Fix problem with zoom an selection rect [#845](https://github.com/penpot/penpot/issues/845) - Fix problem displaying team statistics [#859](https://github.com/penpot/penpot/issues/859) diff --git a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs index 2c0a08f8c4..1fe1c16850 100644 --- a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs @@ -100,7 +100,8 @@ {:cmd :selection/query :page-id page-id :rect rect - :include-frames? true})))) + :include-frames? true + :reverse? true})))) ;; we want the topmost shape to be selected first ;; We use ref so we don't recreate the stream on a change transform-ref (mf/use-ref nil) diff --git a/frontend/src/app/worker/selection.cljs b/frontend/src/app/worker/selection.cljs index dd29d20ccb..2d0ac3a5dd 100644 --- a/frontend/src/app/worker/selection.cljs +++ b/frontend/src/app/worker/selection.cljs @@ -41,8 +41,8 @@ nil)) (defmethod impl/handler :selection/query - [{:keys [page-id rect frame-id include-frames? include-groups? disabled-masks] :or {include-groups? true - disabled-masks #{}} :as message}] + [{:keys [page-id rect frame-id include-frames? include-groups? disabled-masks reverse?] + :or {include-groups? true disabled-masks #{} reverse? false} :as message}] (when-let [index (get @state page-id)] (let [result (-> (qdt/search index (clj->js rect)) (es6-iterator-seq)) @@ -76,11 +76,13 @@ (filter (comp overlaps? :frame)) (filter (comp overlaps-masks? :masks)) (filter overlaps?)) - result)] + result) + + keyfn (if reverse? (comp - :z) :z)] (into (d/ordered-set) (->> matching-shapes - (sort-by (comp - :z)) + (sort-by keyfn) (map :id)))))) (defn create-mask-index