From 0ad4a9ca7e692fdd59a878c928a9faa884de6b00 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Wed, 29 Oct 2025 11:49:14 +0100 Subject: [PATCH] :bug: Fix problem with certain text input and drag/drop --- CHANGES.md | 1 + .../ui/workspace/sidebar/assets/colors.cljs | 4 ++-- .../workspace/sidebar/assets/components.cljs | 18 +++++++++--------- .../workspace/sidebar/assets/typographies.cljs | 4 ++-- .../app/main/ui/workspace/sidebar/sitemap.cljs | 2 +- .../main/ui/workspace/tokens/sets/lists.cljs | 4 ++-- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index bf9b2b2f7f..74b309770f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -70,6 +70,7 @@ - Fix library update notificacions showing when they should not [Taiga #12397](https://tree.taiga.io/project/penpot/issue/12397) - Fix remove flex button doesn’t work within variant [Taiga #12314](https://tree.taiga.io/project/penpot/issue/12314) - Fix an error translation [Taiga #12402](https://tree.taiga.io/project/penpot/issue/12402) +- Fix problem with certain text input in some editable labels (pages, components, tokens...) being in conflict with the drag/drop functionality [Taiga #12316](https://tree.taiga.io/project/penpot/issue/12316) ## 2.10.1 diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets/colors.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets/colors.cljs index 8f6f6325dd..8eb686483e 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets/colors.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets/colors.cljs @@ -169,9 +169,9 @@ on-color-drag-start (mf/use-fn - (mf/deps color file-id selected item-ref read-only?) + (mf/deps color file-id selected item-ref read-only? editing?) (fn [event] - (if read-only? + (if (or read-only? editing?) (dom/prevent-default event) (cmm/on-asset-drag-start event file-id color selected item-ref :colors identity)))) 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 bedf4186e2..b7f8cc121d 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets/components.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets/components.cljs @@ -65,6 +65,7 @@ component-id (:id component) visible? (h/use-visible item-ref :once? true) + renaming? (= renaming (:id component)) ;; NOTE: we don't use reactive deref for it because we don't ;; really need rerender on any change on the file change. If @@ -82,12 +83,13 @@ on-component-double-click (mf/use-fn - (mf/deps file-id component is-local) + (mf/deps file-id component is-local renaming?) (fn [event] (dom/stop-propagation event) - (if is-local - (st/emit! (dwl/go-to-local-component :id component-id)) - (st/emit! (dwl/go-to-component-file file-id component false))))) + (when-not renaming? + (if is-local + (st/emit! (dwl/go-to-local-component :id component-id)) + (st/emit! (dwl/go-to-component-file file-id component false)))))) on-drop (mf/use-fn @@ -113,18 +115,16 @@ on-component-drag-start (mf/use-fn - (mf/deps file-id component selected item-ref on-drag-start read-only? is-local) + (mf/deps file-id component selected item-ref on-drag-start read-only? renaming? is-local) (fn [event] - (if read-only? + (if (or read-only? renaming?) (dom/prevent-default event) (cmm/on-asset-drag-start event file-id component selected item-ref :components on-drag-start)))) on-context-menu (mf/use-fn (mf/deps on-context-menu component-id) - (partial on-context-menu component-id)) - - renaming? (= renaming (:id component))] + (partial on-context-menu component-id))] [:div {:ref item-ref :class (stl/css-case :component-item true diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets/typographies.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets/typographies.cljs index 1f1d5a1704..8ad40c2f4e 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets/typographies.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets/typographies.cljs @@ -76,9 +76,9 @@ on-typography-drag-start (mf/use-fn - (mf/deps typography file-id selected item-ref read-only?) + (mf/deps typography file-id selected item-ref read-only? renaming? open?) (fn [event] - (if read-only? + (if (or read-only? renaming? open?) (dom/prevent-default event) (cmm/on-asset-drag-start event file-id typography selected item-ref :typographies identity)))) diff --git a/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs b/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs index cce3eb7d63..28fe1cee38 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs @@ -113,7 +113,7 @@ :data {:id id :index index :name (:name page)} - :draggable? (not read-only?)) + :draggable? (and (not read-only?) (not editing?))) on-context-menu (mf/use-fn diff --git a/frontend/src/app/main/ui/workspace/tokens/sets/lists.cljs b/frontend/src/app/main/ui/workspace/tokens/sets/lists.cljs index 17710aaee9..89d5fa4895 100644 --- a/frontend/src/app/main/ui/workspace/tokens/sets/lists.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/sets/lists.cljs @@ -162,7 +162,7 @@ :data {:index index :is-group true} :detect-center? true - :draggable? is-draggable)] + :draggable? (and is-draggable (not is-editing)))] [:div {:ref dref :data-testid "tokens-set-group-item" @@ -271,7 +271,7 @@ :on-drop on-drop :data {:index index :is-group false} - :draggable? is-draggable) + :draggable? (and is-draggable (not is-editing))) drop-over (get dprops :over)]