diff --git a/CHANGES.md b/CHANGES.md index 3ecb1cdb7..594c60481 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -67,6 +67,7 @@ - Fix problem with selection colors and texts [Taiga #5079](https://tree.taiga.io/project/penpot/issue/5079) - Remove "show in view mode" flag when moving frame to frame [Taiga #5091](https://tree.taiga.io/project/penpot/issue/5091) - Fix problem creating files in project page [Taiga #5060](https://tree.taiga.io/project/penpot/issue/5060) +- Disable empty names on rename files [Taiga #5088](https://tree.taiga.io/project/penpot/issue/5088) ### :heart: Community contributions by (Thank you!) - To @ondrejkonec: for contributing to the code with: diff --git a/frontend/src/app/main/ui/dashboard/grid.cljs b/frontend/src/app/main/ui/dashboard/grid.cljs index eba451495..c0d4b1c0a 100644 --- a/frontend/src/app/main/ui/dashboard/grid.cljs +++ b/frontend/src/app/main/ui/dashboard/grid.cljs @@ -268,7 +268,9 @@ (mf/use-fn (mf/deps file) (fn [name] - (st/emit! (dd/rename-file (assoc file :name name))) + (let [name (str/trim name)] + (when (not= name "") + (st/emit! (dd/rename-file (assoc file :name name))))) (swap! local assoc :edition false))) on-edit diff --git a/frontend/src/app/main/ui/dashboard/import.cljs b/frontend/src/app/main/ui/dashboard/import.cljs index 7bc0966ca..1aa8fbc73 100644 --- a/frontend/src/app/main/ui/dashboard/import.cljs +++ b/frontend/src/app/main/ui/dashboard/import.cljs @@ -22,6 +22,7 @@ [app.util.keyboard :as kbd] [app.util.webapi :as wapi] [beicon.core :as rx] + [cuerdas.core :as str] [potok.core :as ptk] [rumext.v2 :as mf])) @@ -61,9 +62,11 @@ (->> files (mapv (fn [file] - (cond-> file - (= (:file-id file) file-id) - (assoc :name new-name)))))) + (let [new-name (str/trim new-name)] + (cond-> file + (and (= (:file-id file) file-id) + (not= "" new-name)) + (assoc :name new-name))))))) (defn remove-file [files file-id] (->> files diff --git a/frontend/src/app/main/ui/workspace/header.cljs b/frontend/src/app/main/ui/workspace/header.cljs index 1ccd70f2a..7be23d60d 100644 --- a/frontend/src/app/main/ui/workspace/header.cljs +++ b/frontend/src/app/main/ui/workspace/header.cljs @@ -33,6 +33,7 @@ [app.util.keyboard :as kbd] [app.util.router :as rt] [beicon.core :as rx] + [cuerdas.core :as str] [okulary.core :as l] [potok.core :as ptk] [rumext.v2 :as mf])) @@ -150,10 +151,12 @@ :on-accept #(st/emit! (dwl/set-file-shared (:id file) false)) :count-libraries 1})))) - handle-blur (fn [_] - (let [value (-> edit-input-ref mf/ref-val dom/get-value)] - (st/emit! (dw/rename-file (:id file) value))) - (reset! editing? false)) + handle-blur + (fn [_] + (let [value (str/trim (-> edit-input-ref mf/ref-val dom/get-value))] + (when (not= value "") + (st/emit! (dw/rename-file (:id file) value)))) + (reset! editing? false)) handle-name-keydown (fn [event] (when (kbd/enter? event)