diff --git a/CHANGES.md b/CHANGES.md index 48f4a57f39..200c09be70 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,9 +7,11 @@ ### :boom: Breaking changes & Deprecations ### :heart: Community contributions (Thank you!) + - Design improvements to the Invitations page with an empty state [GitHub #2608](https://github.com/penpot/penpot/issues/2608) by [@iprithvitharun](https://github.com/iprithvitharun) ### :sparkles: New features + - Update board presets with a newer devices [Taiga #10610](https://tree.taiga.io/project/penpot/us/10610) - Propagate "sharing a prototype" to editors and viewers [Taiga #8853](https://tree.taiga.io/project/penpot/us/8853) - Design improvements to the Invitations page with an empty state [Taiga #4554](https://tree.taiga.io/project/penpot/us/4554) @@ -18,6 +20,7 @@ - Display indicator on not active sets [Taiga #10668](https://tree.taiga.io/project/penpot/issue/10668) ### :bug: Bugs fixed + - Fix problem in viewer with the back button [Taiga #10907](https://tree.taiga.io/project/penpot/issue/10907) - Fix resize bar background on tokens panel [Taiga #10811](https://tree.taiga.io/project/penpot/issue/10811) - Fix shortcut for history version panel [Taiga #11006](https://tree.taiga.io/project/penpot/issue/11006) @@ -43,6 +46,7 @@ - Fix Color should preserve color space [Github #69](https://github.com/tokens-studio/penpot/issues/69) - Fix cannot rename Design Token Sets when group of same name exists [Taiga Issue #10773](https://tree.taiga.io/project/penpot/issue/10773) - Fix problem when duplicating grid layout [Github #6391](https://github.com/penpot/penpot/issues/6391) +- Fix issue that makes workspace shortcuts stop working [Taiga #11062](https://tree.taiga.io/project/penpot/issue/11062) ## 2.6.2 diff --git a/frontend/src/app/main/data/shortcuts.cljs b/frontend/src/app/main/data/shortcuts.cljs index 228ae82c74..febed4486e 100644 --- a/frontend/src/app/main/data/shortcuts.cljs +++ b/frontend/src/app/main/data/shortcuts.cljs @@ -8,7 +8,7 @@ (:refer-clojure :exclude [meta reset!]) (:require ["@penpot/mousetrap$default" :as mousetrap] - [app.common.data.macros :as dm] + [app.common.data :as d] [app.common.logging :as log] [app.common.schema :as sm] [app.config :as cf] @@ -135,7 +135,7 @@ [:fn {:optional true} fn?] [:tooltip {:optional true} :string]]]) -(def check-shortcuts! +(def ^:private check-shortcuts (sm/check-fn schema:shortcuts)) (defn- wrap-cb @@ -167,23 +167,20 @@ (mousetrap/reset) (bind! shortcuts))) +(def ^:private conj* + (fnil conj (d/ordered-map))) + (defn push-shortcuts [key shortcuts] + (assert (keyword? key) "expected a keyword for `key`") + (let [shortcuts (check-shortcuts shortcuts)] + (ptk/reify ::push-shortcuts + ptk/UpdateEvent + (update [_ state] + (update state :shortcuts conj* [key shortcuts])) - (dm/assert! - "expected valid parameters" - (and (keyword? key) - (check-shortcuts! shortcuts))) - - (ptk/reify ::push-shortcuts - ptk/UpdateEvent - (update [_ state] - (-> state - (update :shortcuts (fnil conj '()) [key shortcuts]))) - - ptk/EffectEvent - (effect [_ state _] - (let [[_key shortcuts] (peek (:shortcuts state))] + ptk/EffectEvent + (effect [_ _ _] (reset! shortcuts))))) (defn pop-shortcuts @@ -192,12 +189,9 @@ ptk/UpdateEvent (update [_ state] (update state :shortcuts (fn [shortcuts] - (let [current-key (first (peek shortcuts))] - (if (= key current-key) - (pop shortcuts) - shortcuts))))) + (dissoc shortcuts key)))) + ptk/EffectEvent (effect [_ state _] - (let [[key* shortcuts] (peek (:shortcuts state))] - (when (not= key key*) - (reset! shortcuts)))))) + (let [[_key shortcuts] (last (:shortcuts state))] + (reset! shortcuts))))) diff --git a/frontend/src/app/main/ui/workspace/colorpicker.cljs b/frontend/src/app/main/ui/workspace/colorpicker.cljs index e6d9fced39..a6fb5ba9af 100644 --- a/frontend/src/app/main/ui/workspace/colorpicker.cljs +++ b/frontend/src/app/main/ui/workspace/colorpicker.cljs @@ -586,10 +586,10 @@ (mf/with-effect [] (st/emit! (st/emit! (dsc/push-shortcuts ::colorpicker sc/shortcuts))) - #(do - (st/emit! (dsc/pop-shortcuts ::colorpicker)) - (when (and @dirty? @last-change on-close) - (on-close @last-change)))) + (fn [] + (st/emit! (dsc/pop-shortcuts ::colorpicker)) + (when (and @dirty? @last-change on-close) + (on-close @last-change)))) [:div {:class (stl/css :colorpicker-tooltip) :data-testid "colorpicker" diff --git a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs index f0ba58b365..ab4f63135f 100644 --- a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs @@ -472,16 +472,23 @@ (defn setup-shortcuts [path-editing? drawing-path? text-editing? grid-editing?] (hooks/use-shortcuts ::workspace wsc/shortcuts) - (mf/use-effect - (mf/deps path-editing? drawing-path? grid-editing?) - (fn [] - (cond - grid-editing? - (do (st/emit! (dsc/push-shortcuts ::grid gsc/shortcuts)) - #(st/emit! (dsc/pop-shortcuts ::grid))) - (or drawing-path? path-editing?) - (do (st/emit! (dsc/push-shortcuts ::path psc/shortcuts)) - #(st/emit! (dsc/pop-shortcuts ::path))) - text-editing? - (do (st/emit! (dsc/push-shortcuts ::text tsc/shortcuts)) - #(st/emit! (dsc/pop-shortcuts ::text))))))) + + (mf/with-effect [path-editing? drawing-path? grid-editing?] + (cond + grid-editing? + (do + (st/emit! (dsc/push-shortcuts ::grid gsc/shortcuts)) + (fn [] + (st/emit! (dsc/pop-shortcuts ::grid)))) + + (or drawing-path? path-editing?) + (do + (st/emit! (dsc/push-shortcuts ::path psc/shortcuts)) + (fn [] + (st/emit! (dsc/pop-shortcuts ::path)))) + + text-editing? + (do + (st/emit! (dsc/push-shortcuts ::text tsc/shortcuts)) + (fn [] + (st/emit! (dsc/pop-shortcuts ::text)))))))