0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-20 13:55:34 -05:00

Merge pull request #2757 from penpot/palba-fix-expanded-code

🐛 Fix switching tabs produces strange behaviour when "expanded" v…
This commit is contained in:
Alejandro 2023-01-11 12:55:33 +01:00 committed by GitHub
commit 984187037c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 8 deletions

View file

@ -60,7 +60,7 @@
(reset! expanded false) (reset! expanded false)
(reset! section %) (reset! section %)
(when (= from :workspace) (when (= from :workspace)
(dw/set-inspect-expanded false))) (st/emit! (dw/set-inspect-expanded false))))
:selected @section} :selected @section}
[:& tab-element {:id :info :title (tr "inspect.tabs.info")} [:& tab-element {:id :info :title (tr "inspect.tabs.info")}
[:& attributes {:page-id page-id [:& attributes {:page-id page-id

View file

@ -80,17 +80,33 @@
{::mf/wrap-props false {::mf/wrap-props false
::mf/wrap [mf/memo]} ::mf/wrap [mf/memo]}
[props] [props]
(let [layout (obj/get props "layout") (let [layout (obj/get props "layout")
drawing-tool (:tool (mf/deref refs/workspace-drawing)) section (obj/get props "section")
expanded (mf/deref refs/inspect-expanded)] drawing-tool (:tool (mf/deref refs/workspace-drawing))
[:aside.settings-bar.settings-bar-right {:class (when expanded "expanded")} is-comments? (= drawing-tool :comments)
is-history? (contains? layout :document-history)
is-inspect? (= section :inspect)
expanded? (mf/deref refs/inspect-expanded)
can-be-expanded? (and
(not is-comments?)
(not is-history?)
is-inspect?)]
(mf/use-effect
(mf/deps can-be-expanded?)
(fn []
(when (not can-be-expanded?)
(st/emit! (dw/set-inspect-expanded false)))))
[:aside.settings-bar.settings-bar-right {:class (when (and can-be-expanded? expanded?) "expanded")}
[:div.settings-bar-inside [:div.settings-bar-inside
(cond (cond
(= drawing-tool :comments) is-comments?
[:& comments-sidebar] [:& comments-sidebar]
(contains? layout :document-history) is-history?
[:& history-toolbox] [:& history-toolbox]
:else :else

View file

@ -72,7 +72,8 @@
shape-parent-frame (cph/get-frame objects (:frame-id first-selected-shape)) shape-parent-frame (cph/get-frame objects (:frame-id first-selected-shape))
on-change-tab on-change-tab
(fn [options-mode] (fn [options-mode]
(st/emit! (udw/set-options-mode options-mode)) (st/emit! (udw/set-options-mode options-mode)
(udw/set-inspect-expanded false))
(if (= options-mode :inspect) ;;TODO maybe move this logic to set-options-mode (if (= options-mode :inspect) ;;TODO maybe move this logic to set-options-mode
(st/emit! :interrupt (udw/set-workspace-read-only true)) (st/emit! :interrupt (udw/set-workspace-read-only true))
(st/emit! :interrupt (udw/set-workspace-read-only false))))] (st/emit! :interrupt (udw/set-workspace-read-only false))))]