🐛 Fix internal error on layer prev/next sibling selection (#9003)

Signed-off-by: jsdevninja <topit89807@gmail.com>
This commit is contained in:
Full Stack Developer 2026-04-22 06:59:42 -05:00 committed by GitHub
parent 8ad30e14b6
commit d384f47253
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -173,13 +173,17 @@
current (get objects first-selected) current (get objects first-selected)
parent (get objects (:parent-id current)) parent (get objects (:parent-id current))
sibling-ids (:shapes parent) sibling-ids (:shapes parent)
current-index (d/index-of sibling-ids first-selected) ;; `index-of` is nil when the shape is not listed under the parent (stale
sibling (if (= (dec (count sibling-ids)) current-index) ;; selection or inconsistent tree). Do not call `nth` with `(dec nil)` — in
(first sibling-ids) ;; ClojureScript that is -1 and throws (see penpot#7064).
(nth sibling-ids (inc current-index)))] current-index (some-> sibling-ids (d/index-of first-selected))
sibling (when (some? current-index)
(if (= (dec (count sibling-ids)) current-index)
(first sibling-ids)
(nth sibling-ids (inc current-index) nil)))]
(cond (cond
(= 1 count-selected) (and (= 1 count-selected) (some? sibling))
(rx/of (select-shape sibling)) (rx/of (select-shape sibling))
(> count-selected 1) (> count-selected 1)
@ -198,12 +202,13 @@
current (get objects first-selected) current (get objects first-selected)
parent (get objects (:parent-id current)) parent (get objects (:parent-id current))
sibling-ids (:shapes parent) sibling-ids (:shapes parent)
current-index (d/index-of sibling-ids first-selected) current-index (some-> sibling-ids (d/index-of first-selected))
sibling (if (= 0 current-index) sibling (when (some? current-index)
(last sibling-ids) (if (= 0 current-index)
(nth sibling-ids (dec current-index)))] (last sibling-ids)
(nth sibling-ids (dec current-index) nil)))]
(cond (cond
(= 1 count-selected) (and (= 1 count-selected) (some? sibling))
(rx/of (select-shape sibling)) (rx/of (select-shape sibling))
(> count-selected 1) (> count-selected 1)