diff --git a/frontend/src/app/main/ui/viewer/inspect/right_sidebar.cljs b/frontend/src/app/main/ui/viewer/inspect/right_sidebar.cljs index 4d548806c9..c8a4964097 100644 --- a/frontend/src/app/main/ui/viewer/inspect/right_sidebar.cljs +++ b/frontend/src/app/main/ui/viewer/inspect/right_sidebar.cljs @@ -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 diff --git a/frontend/src/app/main/ui/workspace/sidebar.cljs b/frontend/src/app/main/ui/workspace/sidebar.cljs index 3c37c0defc..cf61c1e9ec 100644 --- a/frontend/src/app/main/ui/workspace/sidebar.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar.cljs @@ -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 diff --git a/frontend/src/app/main/ui/workspace/sidebar/options.cljs b/frontend/src/app/main/ui/workspace/sidebar/options.cljs index 9cdfdcf154..00a136f1c7 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options.cljs @@ -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))))]