🐛 Fix double click crash on viewer layers

This commit is contained in:
Eva 2022-06-21 10:45:26 +02:00
parent 95829ff3de
commit ac1167d0c9
3 changed files with 12 additions and 4 deletions

View file

@ -72,7 +72,7 @@
:icon-layer (= (:type item) :icon))
:on-click select-shape}
[:& si/element-icon {:shape item}]
[:& layer-name {:shape item}]
[:& layer-name {:shape item :disabled-double-click true}]
(when (and (not disable-collapse?) (:shapes item))
[:span.toggle-content

View file

@ -32,13 +32,14 @@
(l/derived (l/in [:workspace-local :shape-for-rename]) st/state))
(mf/defc layer-name
[{:keys [shape on-start-edit on-stop-edit name-ref] :as props}]
[{:keys [shape on-start-edit disabled-double-click on-stop-edit name-ref] :as props}]
(let [local (mf/use-state {})
shape-for-rename (mf/deref shape-for-rename-ref)
start-edit (fn []
(on-start-edit)
(swap! local assoc :edition true))
(when (not disabled-double-click)
(on-start-edit)
(swap! local assoc :edition true)))
accept-edit (fn []
(let [name-input (mf/ref-val name-ref)