diff --git a/CHANGES.md b/CHANGES.md index 5617a320b..f6e0c7250 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -71,6 +71,7 @@ - Fix error screen on upload image error [Taiga #5608](https://tree.taiga.io/project/penpot/issue/5608) - Fix bad frame-id for certain componentes [#3205](https://github.com/penpot/penpot/issues/3205) - Fix paste elements at bottom of frame [Taig #5253](https://tree.taiga.io/project/penpot/issue/5253) +- Fix new-file button on project not redirecting to the new file [Taiga #5610](https://tree.taiga.io/project/penpot/issue/5610) ### :arrow_up: Deps updates diff --git a/frontend/src/app/main/ui/dashboard/files.cljs b/frontend/src/app/main/ui/dashboard/files.cljs index b7d9426cf..1ad4e9ada 100644 --- a/frontend/src/app/main/ui/dashboard/files.cljs +++ b/frontend/src/app/main/ui/dashboard/files.cljs @@ -18,6 +18,7 @@ [app.util.dom :as dom] [app.util.i18n :as i18n :refer [tr]] [app.util.keyboard :as kbd] + [app.util.router :as rt] [app.util.webapi :as wapi] [beicon.core :as rx] [cuerdas.core :as str] @@ -142,12 +143,22 @@ (sort-by :modified-at) (reverse))) + on-file-created + (mf/use-fn + (fn [data] + (let [pparams {:project-id (:project-id data) + :file-id (:id data)} + qparams {:page-id (get-in data [:data :pages 0])}] + (st/emit! (rt/nav :workspace pparams qparams))))) + create-file (mf/use-fn (mf/deps project) (fn [origin] - (st/emit! (with-meta (dd/create-file {:project-id (:id project)}) - {::ev/origin origin}))))] + (let [mdata {:on-success on-file-created} + params {:project-id (:id project)}] + (st/emit! (-> (dd/create-file (with-meta params mdata)) + (with-meta {::ev/origin origin}))))))] (mf/with-effect [] (let [node (mf/ref-val rowref)