0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-13 18:48:37 -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! section %)
(when (= from :workspace)
(dw/set-inspect-expanded false)))
(st/emit! (dw/set-inspect-expanded false))))
:selected @section}
[:& tab-element {:id :info :title (tr "inspect.tabs.info")}
[:& attributes {:page-id page-id

View file

@ -80,17 +80,33 @@
{::mf/wrap-props false
::mf/wrap [mf/memo]}
[props]
(let [layout (obj/get props "layout")
drawing-tool (:tool (mf/deref refs/workspace-drawing))
expanded (mf/deref refs/inspect-expanded)]
(let [layout (obj/get props "layout")
section (obj/get props "section")
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
(cond
(= drawing-tool :comments)
is-comments?
[:& comments-sidebar]
(contains? layout :document-history)
is-history?
[:& history-toolbox]
:else

View file

@ -72,7 +72,8 @@
shape-parent-frame (cph/get-frame objects (:frame-id first-selected-shape))
on-change-tab
(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
(st/emit! :interrupt (udw/set-workspace-read-only true))
(st/emit! :interrupt (udw/set-workspace-read-only false))))]