mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 07:41:43 -05:00
🐛 Avoid empty names in projects, files and pages
This commit is contained in:
parent
918829ad0a
commit
9dfd5c0bcc
5 changed files with 19 additions and 10 deletions
|
@ -74,6 +74,7 @@
|
|||
- Fix auto hide header in viewer full screen [Taiga #2632](https://tree.taiga.io/project/penpot/issue/2632)
|
||||
- Fix zoom in/out after fit or fill [Taiga #2630](https://tree.taiga.io/project/penpot/issue/2630)
|
||||
- Normalize zoom levels in workspace and viewer [Taiga #2631](https://tree.taiga.io/project/penpot/issue/2631)
|
||||
- Avoid empty names in projects, files and pages [Taiga #2594](https://tree.taiga.io/project/penpot/issue/2594)
|
||||
|
||||
### :arrow_up: Deps updates
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
[app.main.ui.icons :as i]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[cuerdas.core :as str]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(mf/defc header
|
||||
|
@ -63,9 +64,11 @@
|
|||
(if (:edition @local)
|
||||
[:& inline-edition {:content (:name project)
|
||||
:on-end (fn [name]
|
||||
(st/emit! (-> (dd/rename-project (assoc project :name name))
|
||||
(with-meta {::ev/origin "project"})))
|
||||
(swap! local assoc :edition false))}]
|
||||
(let [name (str/trim name)]
|
||||
(when-not (str/empty? name)
|
||||
(st/emit! (-> (dd/rename-project (assoc project :name name))
|
||||
(with-meta {::ev/origin "project"}))))
|
||||
(swap! local assoc :edition false)))}]
|
||||
[:div.dashboard-title
|
||||
[:h1 {:on-double-click on-edit}
|
||||
(:name project)]]))
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.router :as rt]
|
||||
[app.util.time :as dt]
|
||||
[cuerdas.core :as str]
|
||||
[okulary.core :as l]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
|
@ -73,9 +74,11 @@
|
|||
(mf/use-callback
|
||||
(mf/deps project)
|
||||
(fn [name]
|
||||
(st/emit! (-> (dd/rename-project (assoc project :name name))
|
||||
(with-meta {::ev/origin "dashboard"})))
|
||||
(swap! local assoc :edition? false)))
|
||||
(let [name (str/trim name)]
|
||||
(when-not (str/empty? name)
|
||||
(st/emit! (-> (dd/rename-project (assoc project :name name))
|
||||
(with-meta {::ev/origin "dashboard"}))))
|
||||
(swap! local assoc :edition? false))))
|
||||
|
||||
on-file-created
|
||||
(mf/use-callback
|
||||
|
|
|
@ -70,8 +70,8 @@
|
|||
(on-stop-edit)
|
||||
(swap! local assoc :edition false)
|
||||
(st/emit! (dw/end-rename-shape)
|
||||
(when-not (str/empty? name)
|
||||
(dw/update-shape (:id shape) {:name name})))))
|
||||
(when-not (str/empty? (str/trim name))
|
||||
(dw/update-shape (:id shape) {:name (str/trim name)})))))
|
||||
|
||||
cancel-edit (fn []
|
||||
(on-stop-edit)
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.keyboard :as kbd]
|
||||
[cuerdas.core :as str]
|
||||
[okulary.core :as l]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
|
@ -66,8 +67,9 @@
|
|||
(mf/use-callback
|
||||
(fn [event]
|
||||
(let [target (dom/event->target event)
|
||||
name (dom/get-value target)]
|
||||
(st/emit! (dw/rename-page id name))
|
||||
name (str/trim (dom/get-value target))]
|
||||
(when-not (str/empty? name)
|
||||
(st/emit! (dw/rename-page id name)))
|
||||
(swap! local assoc :edition false))))
|
||||
|
||||
on-key-down
|
||||
|
|
Loading…
Add table
Reference in a new issue