mirror of
https://github.com/penpot/penpot.git
synced 2025-05-29 20:56:13 +02:00
🐛 Fix issue on shortcuts restore operation (#6462)
* 🐛 Fix issue on shortcuts restore operation Happens when the order of shortcuts pop events is inconsistent with push events. Using less strictly order policy for pop operations allows relax this and make it eventually consistent. * 💄 Add cosmetic changes on shortcuts hooks on colorpicker and wport * 📎 Update changelog * 📎 Add PR feedback changes
This commit is contained in:
parent
70b1989f10
commit
86bcd1b681
4 changed files with 45 additions and 40 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
||||
(dm/assert!
|
||||
"expected valid parameters"
|
||||
(and (keyword? key)
|
||||
(check-shortcuts! shortcuts)))
|
||||
|
||||
(assert (keyword? key) "expected a keyword for `key`")
|
||||
(let [shortcuts (check-shortcuts shortcuts)]
|
||||
(ptk/reify ::push-shortcuts
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(-> state
|
||||
(update :shortcuts (fnil conj '()) [key shortcuts])))
|
||||
(update state :shortcuts conj* [key shortcuts]))
|
||||
|
||||
ptk/EffectEvent
|
||||
(effect [_ state _]
|
||||
(let [[_key shortcuts] (peek (:shortcuts state))]
|
||||
(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)))))
|
||||
|
|
|
@ -586,7 +586,7 @@
|
|||
|
||||
(mf/with-effect []
|
||||
(st/emit! (st/emit! (dsc/push-shortcuts ::colorpicker sc/shortcuts)))
|
||||
#(do
|
||||
(fn []
|
||||
(st/emit! (dsc/pop-shortcuts ::colorpicker))
|
||||
(when (and @dirty? @last-change on-close)
|
||||
(on-close @last-change))))
|
||||
|
|
|
@ -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 []
|
||||
|
||||
(mf/with-effect [path-editing? drawing-path? grid-editing?]
|
||||
(cond
|
||||
grid-editing?
|
||||
(do (st/emit! (dsc/push-shortcuts ::grid gsc/shortcuts))
|
||||
#(st/emit! (dsc/pop-shortcuts ::grid)))
|
||||
(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))
|
||||
#(st/emit! (dsc/pop-shortcuts ::path)))
|
||||
(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))
|
||||
#(st/emit! (dsc/pop-shortcuts ::text)))))))
|
||||
(do
|
||||
(st/emit! (dsc/push-shortcuts ::text tsc/shortcuts))
|
||||
(fn []
|
||||
(st/emit! (dsc/pop-shortcuts ::text)))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue