mirror of
https://github.com/penpot/penpot.git
synced 2026-09-11 14:39:35 +00:00
🐛 Fix objects sorting for thumbnail generation
This commit is contained in:
parent
8637c46ba1
commit
f94c9cdb02
@ -1131,10 +1131,28 @@
|
|||||||
maintaining proper shape reference consistency in WASM."
|
maintaining proper shape reference consistency in WASM."
|
||||||
[objects]
|
[objects]
|
||||||
;; Get IDs in tree order starting from root (uuid/zero)
|
;; Get IDs in tree order starting from root (uuid/zero)
|
||||||
(let [ordered-ids (cfh/get-children-ids-with-self objects uuid/zero)]
|
;; If root doesn't exist (e.g., filtered thumbnail data), fall back to
|
||||||
(into []
|
;; finding top-level shapes (those without a parent in objects) and
|
||||||
(keep #(get objects %))
|
;; traversing from there.
|
||||||
ordered-ids)))
|
(if (contains? objects uuid/zero)
|
||||||
|
;; Normal case: traverse from root
|
||||||
|
(let [ordered-ids (cfh/get-children-ids-with-self objects uuid/zero)]
|
||||||
|
(into []
|
||||||
|
(keep #(get objects %))
|
||||||
|
ordered-ids))
|
||||||
|
;; Fallback for filtered data (thumbnails): find top-level shapes and traverse
|
||||||
|
(let [;; Find shapes whose parent is not in the objects map (top-level in this subset)
|
||||||
|
top-level-ids (->> (vals objects)
|
||||||
|
(filter (fn [shape]
|
||||||
|
(not (contains? objects (:parent-id shape)))))
|
||||||
|
(map :id))
|
||||||
|
;; Get all children in order for each top-level shape
|
||||||
|
all-ordered-ids (into []
|
||||||
|
(mapcat #(cfh/get-children-ids-with-self objects %))
|
||||||
|
top-level-ids)]
|
||||||
|
(into []
|
||||||
|
(keep #(get objects %))
|
||||||
|
all-ordered-ids))))
|
||||||
|
|
||||||
(defn set-objects
|
(defn set-objects
|
||||||
"Set all shape objects for rendering.
|
"Set all shape objects for rendering.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user