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 87eb89ce13..8c22f87fc5 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs @@ -300,7 +300,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))] @@ -321,14 +321,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 @@ -417,11 +421,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 @@ -502,4 +502,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 dad9f6a6b1..d600d26a8b 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/layer_item.scss +++ b/frontend/src/app/main/ui/workspace/sidebar/layer_item.scss @@ -298,3 +298,7 @@ .filtered { min-inline-size: $sz-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 de90c9bbfe..282eca00e8 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/layers.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/layers.cljs @@ -521,8 +521,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