mirror of
https://github.com/penpot/penpot.git
synced 2025-05-29 20:46:10 +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
|
### :boom: Breaking changes & Deprecations
|
||||||
|
|
||||||
### :heart: Community contributions (Thank you!)
|
### :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)
|
- 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
|
### :sparkles: New features
|
||||||
|
|
||||||
- Update board presets with a newer devices [Taiga #10610](https://tree.taiga.io/project/penpot/us/10610)
|
- 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)
|
- 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)
|
- 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)
|
- Display indicator on not active sets [Taiga #10668](https://tree.taiga.io/project/penpot/issue/10668)
|
||||||
|
|
||||||
### :bug: Bugs fixed
|
### :bug: Bugs fixed
|
||||||
|
|
||||||
- Fix problem in viewer with the back button [Taiga #10907](https://tree.taiga.io/project/penpot/issue/10907)
|
- 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 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)
|
- 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 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 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 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
|
## 2.6.2
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(:refer-clojure :exclude [meta reset!])
|
(:refer-clojure :exclude [meta reset!])
|
||||||
(:require
|
(:require
|
||||||
["@penpot/mousetrap$default" :as mousetrap]
|
["@penpot/mousetrap$default" :as mousetrap]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data :as d]
|
||||||
[app.common.logging :as log]
|
[app.common.logging :as log]
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
|
@ -135,7 +135,7 @@
|
||||||
[:fn {:optional true} fn?]
|
[:fn {:optional true} fn?]
|
||||||
[:tooltip {:optional true} :string]]])
|
[:tooltip {:optional true} :string]]])
|
||||||
|
|
||||||
(def check-shortcuts!
|
(def ^:private check-shortcuts
|
||||||
(sm/check-fn schema:shortcuts))
|
(sm/check-fn schema:shortcuts))
|
||||||
|
|
||||||
(defn- wrap-cb
|
(defn- wrap-cb
|
||||||
|
@ -167,23 +167,20 @@
|
||||||
(mousetrap/reset)
|
(mousetrap/reset)
|
||||||
(bind! shortcuts)))
|
(bind! shortcuts)))
|
||||||
|
|
||||||
|
(def ^:private conj*
|
||||||
|
(fnil conj (d/ordered-map)))
|
||||||
|
|
||||||
(defn push-shortcuts
|
(defn push-shortcuts
|
||||||
[key 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!
|
ptk/EffectEvent
|
||||||
"expected valid parameters"
|
(effect [_ _ _]
|
||||||
(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))]
|
|
||||||
(reset! shortcuts)))))
|
(reset! shortcuts)))))
|
||||||
|
|
||||||
(defn pop-shortcuts
|
(defn pop-shortcuts
|
||||||
|
@ -192,12 +189,9 @@
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(update state :shortcuts (fn [shortcuts]
|
(update state :shortcuts (fn [shortcuts]
|
||||||
(let [current-key (first (peek shortcuts))]
|
(dissoc shortcuts key))))
|
||||||
(if (= key current-key)
|
|
||||||
(pop shortcuts)
|
|
||||||
shortcuts)))))
|
|
||||||
ptk/EffectEvent
|
ptk/EffectEvent
|
||||||
(effect [_ state _]
|
(effect [_ state _]
|
||||||
(let [[key* shortcuts] (peek (:shortcuts state))]
|
(let [[_key shortcuts] (last (:shortcuts state))]
|
||||||
(when (not= key key*)
|
(reset! shortcuts)))))
|
||||||
(reset! shortcuts))))))
|
|
||||||
|
|
|
@ -586,10 +586,10 @@
|
||||||
|
|
||||||
(mf/with-effect []
|
(mf/with-effect []
|
||||||
(st/emit! (st/emit! (dsc/push-shortcuts ::colorpicker sc/shortcuts)))
|
(st/emit! (st/emit! (dsc/push-shortcuts ::colorpicker sc/shortcuts)))
|
||||||
#(do
|
(fn []
|
||||||
(st/emit! (dsc/pop-shortcuts ::colorpicker))
|
(st/emit! (dsc/pop-shortcuts ::colorpicker))
|
||||||
(when (and @dirty? @last-change on-close)
|
(when (and @dirty? @last-change on-close)
|
||||||
(on-close @last-change))))
|
(on-close @last-change))))
|
||||||
|
|
||||||
[:div {:class (stl/css :colorpicker-tooltip)
|
[:div {:class (stl/css :colorpicker-tooltip)
|
||||||
:data-testid "colorpicker"
|
:data-testid "colorpicker"
|
||||||
|
|
|
@ -472,16 +472,23 @@
|
||||||
(defn setup-shortcuts
|
(defn setup-shortcuts
|
||||||
[path-editing? drawing-path? text-editing? grid-editing?]
|
[path-editing? drawing-path? text-editing? grid-editing?]
|
||||||
(hooks/use-shortcuts ::workspace wsc/shortcuts)
|
(hooks/use-shortcuts ::workspace wsc/shortcuts)
|
||||||
(mf/use-effect
|
|
||||||
(mf/deps path-editing? drawing-path? grid-editing?)
|
(mf/with-effect [path-editing? drawing-path? grid-editing?]
|
||||||
(fn []
|
(cond
|
||||||
(cond
|
grid-editing?
|
||||||
grid-editing?
|
(do
|
||||||
(do (st/emit! (dsc/push-shortcuts ::grid gsc/shortcuts))
|
(st/emit! (dsc/push-shortcuts ::grid gsc/shortcuts))
|
||||||
#(st/emit! (dsc/pop-shortcuts ::grid)))
|
(fn []
|
||||||
(or drawing-path? path-editing?)
|
(st/emit! (dsc/pop-shortcuts ::grid))))
|
||||||
(do (st/emit! (dsc/push-shortcuts ::path psc/shortcuts))
|
|
||||||
#(st/emit! (dsc/pop-shortcuts ::path)))
|
(or drawing-path? path-editing?)
|
||||||
text-editing?
|
(do
|
||||||
(do (st/emit! (dsc/push-shortcuts ::text tsc/shortcuts))
|
(st/emit! (dsc/push-shortcuts ::path psc/shortcuts))
|
||||||
#(st/emit! (dsc/pop-shortcuts ::text)))))))
|
(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)))))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue