From a7c1de647888b95f7f5c82b51b156aa4d0420d34 Mon Sep 17 00:00:00 2001 From: Elena Torro Date: Mon, 2 Feb 2026 17:13:53 +0100 Subject: [PATCH] :bug: Fix lazy load intersection on dragging at the beginning --- .../main/ui/workspace/sidebar/layer_item.cljs | 22 +++++++++---------- .../main/ui/workspace/sidebar/layer_item.scss | 4 ++++ .../app/main/ui/workspace/sidebar/layers.cljs | 3 +-- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs b/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs index d65b1cbfc8..e295cdad91 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs @@ -302,7 +302,7 @@ on-drop (mf/use-fn - (mf/deps id index objects expanded? selected) + (mf/deps id objects expanded? selected) (fn [side _data] (let [single? (= (count selected) 1) same? (and single? (= (first selected) id))] @@ -323,14 +323,18 @@ [parent-id _] (ctn/find-valid-parent-and-frame-ids parent-id objects (map #(get objects %) selected) false files) - parent (get objects parent-id) + parent (get objects parent-id) + current-index (d/index-of (:shapes parent) id) to-index (cond (= side :center) 0 (and expanded? (= side :bot) (d/not-empty? (:shapes shape))) (count (:shapes parent)) - (= side :top) (inc index) - :else index)] - (st/emit! (dw/relocate-selected-shapes parent-id to-index))))))) + ;; target not found in parent (while lazy loading) + (neg? current-index) nil + (= side :top) (inc current-index) + :else current-index)] + (when (some? to-index) + (st/emit! (dw/relocate-selected-shapes parent-id to-index)))))))) on-hold (mf/use-fn @@ -419,11 +423,7 @@ current @children-count* new-count (min total (max current chunk-size min-count))] (reset! children-count* new-count)) - (reset! children-count* 0))) - (fn [] - (when-let [obs ^js @observer-var] - (.disconnect obs) - (reset! observer-var nil)))) + (reset! children-count* 0)))) ;; Re-observe sentinel whenever children-count changes (sentinel moves) ;; and (shapes item) to reconnect observer after shape changes @@ -504,4 +504,4 @@ :component-child? component-tree?}]))) (when (< children-count (count (:shapes item))) [:div {:ref lazy-ref - :style {:min-height 1}}])])])) + :class (stl/css :lazy-load-sentinel)}])])])) diff --git a/frontend/src/app/main/ui/workspace/sidebar/layer_item.scss b/frontend/src/app/main/ui/workspace/sidebar/layer_item.scss index 43455c1bd0..749f25bf61 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/layer_item.scss +++ b/frontend/src/app/main/ui/workspace/sidebar/layer_item.scss @@ -270,3 +270,7 @@ .filtered { min-width: deprecated.$s-12; } +.lazy-load-sentinel { + min-height: 1px; + pointer-events: none; +} diff --git a/frontend/src/app/main/ui/workspace/sidebar/layers.cljs b/frontend/src/app/main/ui/workspace/sidebar/layers.cljs index 398473f54c..dabe7aae77 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/layers.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/layers.cljs @@ -522,8 +522,7 @@ [:& filters-tree {:objects filtered-objects :key (dm/str (:id page)) :parent-size size-parent}] - [:div {:ref lazy-load-ref - :style {:min-height 16}}]] + [:div {:ref lazy-load-ref}]] [:div {:on-scroll on-scroll :class (stl/css :tool-window-content) :data-scroll-container true