0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-15 03:28:25 -05:00

🐛 Fix problem when duplicating/moving tracks

This commit is contained in:
alonso.torres 2024-01-03 12:20:42 +01:00
parent 5159438e5d
commit 3ae1a97bc9

View file

@ -622,7 +622,7 @@
(defn remove-cell-areas (defn remove-cell-areas
"Remove the areas in the given `index` before and after the index" "Remove the areas in the given `index` before and after the index"
[parent prop index] [parent prop index]
(let [prop-span (if (= prop :column) :row-span :column-span) (let [prop-span (if (= prop :column) :column-span :row-span)
cells (if (= prop :column) (cells-by-column parent index) (cells-by-row parent index))] cells (if (= prop :column) (cells-by-column parent index) (cells-by-row parent index))]
(->> cells (->> cells
(filter #(> (get % prop-span) 1)) (filter #(> (get % prop-span) 1))
@ -654,7 +654,7 @@
"Remove the areas in the given `index` but only after the index." "Remove the areas in the given `index` but only after the index."
[parent prop index] [parent prop index]
(let [prop-span (if (= prop :column) :column-span :row-span) (let [prop-span (if (= prop :column) :column-span :row-span)
cells (if (= type :column) (cells-by-column parent index) (cells-by-row parent index))] cells (if (= prop :column) (cells-by-column parent index) (cells-by-row parent index))]
(->> cells (->> cells
(filter #(> (get % prop-span) 1)) (filter #(> (get % prop-span) 1))
(reduce (reduce
@ -924,7 +924,7 @@
(cond-> parent (cond-> parent
move-content? move-content?
(-> (remove-cell-areas prop (dec from-track)) (-> (remove-cell-areas prop (dec from-track))
(remove-cell-areas prop (dec to-track)))) (remove-cell-areas-after prop (- to-track 2))))
parent parent
(reorder-grid-tracks parent tracks-props from-index to-index)] (reorder-grid-tracks parent tracks-props from-index to-index)]
@ -1376,24 +1376,26 @@
(cells-by-row parent index true)) (cells-by-row parent index true))
([parent index check-span?] ([parent index check-span?]
(->> (:layout-grid-cells parent) (->> (:layout-grid-cells parent)
(filter (fn [[_ {:keys [row row-span]}]] (vals)
(if check-span? (filter
(and (>= (inc index) row) (fn [{:keys [row row-span]}]
(< (inc index) (+ row row-span))) (if check-span?
(= (inc index) row)))) (and (>= (inc index) row)
(map second)))) (< (inc index) (+ row row-span)))
(= (inc index) row)))))))
(defn cells-by-column (defn cells-by-column
([parent index] ([parent index]
(cells-by-column parent index true)) (cells-by-column parent index true))
([parent index check-span?] ([parent index check-span?]
(->> (:layout-grid-cells parent) (->> (:layout-grid-cells parent)
(filter (fn [[_ {:keys [column column-span]}]] (vals)
(if check-span? (filter
(and (>= (inc index) column) (fn [{:keys [column column-span] :as cell}]
(< (inc index) (+ column column-span))) (if check-span?
(= (inc index) column)))) (and (>= (inc index) column)
(map second)))) (< (inc index) (+ column column-span)))
(= (inc index) column)))))))
(defn shapes-by-row (defn shapes-by-row
([parent index] ([parent index]