diff --git a/frontend/src/app/main/ui/components/portal.cljs b/frontend/src/app/main/ui/components/portal.cljs index 5fadf20e7..27ebaa205 100644 --- a/frontend/src/app/main/ui/components/portal.cljs +++ b/frontend/src/app/main/ui/components/portal.cljs @@ -6,10 +6,11 @@ (ns app.main.ui.components.portal (:require + [app.util.dom :as dom] [rumext.v2 :as mf])) (mf/defc portal-on-document* [{:keys [children]}] (mf/portal (mf/html [:* children]) - (.-body js/document))) + (dom/get-body))) diff --git a/frontend/src/app/main/ui/modal.cljs b/frontend/src/app/main/ui/modal.cljs index 3aa83a9ac..9d260de69 100644 --- a/frontend/src/app/main/ui/modal.cljs +++ b/frontend/src/app/main/ui/modal.cljs @@ -86,4 +86,4 @@ (when-let [modal (mf/deref ref:modal)] (mf/portal (mf/html [:> modal-wrapper* {:data modal :key (dm/str (:id modal))}]) - (.-body js/document)))) + (dom/get-body)))) diff --git a/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs b/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs index 9a96b634a..b5712a4c1 100644 --- a/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs @@ -446,17 +446,22 @@ (mf/set-ref-val! dropdown-direction-change* (inc (mf/ref-val dropdown-direction-change*))))))) ;; FIXME: perf optimization - [:& dropdown {:show is-open? - :on-close #(st/emit! (dt/assign-token-context-menu nil))} - [:div {:class (stl/css :token-context-menu) - :data-testid "tokens-context-menu-for-token" - :ref dropdown-ref - :data-direction dropdown-direction - :style {:--bottom (if (= dropdown-direction "up") - "40px" - "unset") - :--top (dm/str top "px") - :left (dm/str left "px")} - :on-context-menu prevent-default} - (when mdata - [:& token-context-menu-tree (assoc mdata :width @width :direction dropdown-direction)])]])) + + (when is-open? + (mf/portal + (mf/html + [:& dropdown {:show is-open? + :on-close #(st/emit! (dt/assign-token-context-menu nil))} + [:div {:class (stl/css :token-context-menu) + :data-testid "tokens-context-menu-for-token" + :ref dropdown-ref + :data-direction dropdown-direction + :style {:--bottom (if (= dropdown-direction "up") + "40px" + "unset") + :--top (dm/str top "px") + :left (dm/str left "px")} + :on-context-menu prevent-default} + (when mdata + [:& token-context-menu-tree (assoc mdata :width @width :direction dropdown-direction)])]]) + (dom/get-body))))) diff --git a/frontend/src/app/main/ui/workspace/tokens/theme_select.cljs b/frontend/src/app/main/ui/workspace/tokens/theme_select.cljs index df81cf6f0..5ef0fff00 100644 --- a/frontend/src/app/main/ui/workspace/tokens/theme_select.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/theme_select.cljs @@ -139,4 +139,4 @@ [:& theme-options {:active-theme-paths active-theme-paths :themes themes :on-close on-close-dropdown}]]]) - (.-body js/document)))])) + (dom/get-body)))]))