From 78aafa4635349e1d526d6ceff4f4bb92a2a7231f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Albeza?= Date: Wed, 27 Mar 2024 11:55:17 +0100 Subject: [PATCH] :bug: Fix layer and component names inputs not having their text selectable on Firefox --- frontend/src/app/main/ui/hooks.cljs | 5 +-- .../workspace/sidebar/assets/components.cljs | 35 ++++++++++--------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/frontend/src/app/main/ui/hooks.cljs b/frontend/src/app/main/ui/hooks.cljs index 944d32ac7..bb05d2b1c 100644 --- a/frontend/src/app/main/ui/hooks.cljs +++ b/frontend/src/app/main/ui/hooks.cljs @@ -177,8 +177,9 @@ on-mount (fn [] (let [dom (mf/ref-val ref)] - (.setAttribute dom "draggable" true) ;; In firefox it needs to be draggable for problems with event handling. - ;; It will stop the drag operation in on-drag-start + ;; In firefox it needs to be draggable for problems with event handling. + ;; It will stop the drag operation in on-drag-start + (.setAttribute dom "draggable" (and draggable? (not disabled))) ;; Register all events in the (default) bubble mode, so that they ;; are captured by the most leaf item. The handler will stop diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets/components.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets/components.cljs index 65a109333..72e01e609 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets/components.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets/components.cljs @@ -141,14 +141,16 @@ on-context-menu (mf/use-fn (mf/deps on-context-menu component-id) - (partial on-context-menu component-id))] + (partial on-context-menu component-id)) + + renaming? (= renaming (:id component))] [:div {:ref item-ref :class (stl/css-case :selected (contains? selected (:id component)) :grid-cell listing-thumbs? :enum-item (not listing-thumbs?)) :id (dm/str "component-shape-id-" (:id component)) - :draggable (not read-only?) + :draggable (and (not read-only?) (not renaming?)) :on-click on-component-click :on-double-click on-component-double-click :on-context-menu on-context-menu @@ -160,22 +162,21 @@ (when (and (some? root-shape) (some? container)) [:* - (let [renaming? (= renaming (:id component))] - [:* - [:& editable-label - {:class (stl/css-case :cell-name listing-thumbs? - :item-name (not listing-thumbs?) - :editing renaming?) - :value (cfh/merge-path-item (:path component) (:name component)) - :tooltip (cfh/merge-path-item (:path component) (:name component)) - :display-value (:name component) - :editing renaming? - :disable-dbl-click true - :on-change do-rename - :on-cancel cancel-rename}] + [:* + [:& editable-label + {:class (stl/css-case :cell-name listing-thumbs? + :item-name (not listing-thumbs?) + :editing renaming?) + :value (cfh/merge-path-item (:path component) (:name component)) + :tooltip (cfh/merge-path-item (:path component) (:name component)) + :display-value (:name component) + :editing renaming? + :disable-dbl-click true + :on-change do-rename + :on-cancel cancel-rename}] - (when ^boolean dragging? - [:div {:class (stl/css :dragging)}])]) + (when ^boolean dragging? + [:div {:class (stl/css :dragging)}])] (when visible? [:& cmm/component-item-thumbnail {:file-id file-id