diff --git a/frontend/src/app/main/ui/workspace/context_menu.cljs b/frontend/src/app/main/ui/workspace/context_menu.cljs index 163932f53e..d28363d571 100644 --- a/frontend/src/app/main/ui/workspace/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/context_menu.cljs @@ -719,6 +719,7 @@ :title (:title entry) :shortcut (when sc-key (get-tt sc-key)) :shortcut-key sc-key + :disabled (:disabled entry) :on-click (:action entry)}]))]) (when variant-container? diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs index 243f47c196..986b016601 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs @@ -10,6 +10,7 @@ (:require [app.common.data.macros :as dm] [app.common.files.helpers :as cfh] + [app.common.logic.libraries :as cll] [app.common.path-names :as cpn] [app.common.thumbnails :as thc] [app.common.types.component :as ctk] @@ -454,6 +455,10 @@ (not (ctn/has-any-copy-parent? objects shape)) (cfh/component-touched? objects (:id shape)))) + ;; Updating the main would nest its component inside itself. + update-main-loop? (and can-update-main? + (cll/update-main-nesting-loop? libraries {:objects objects} shape-id)) + can-detach? (and (seq copies) (every? #(not (ctn/has-any-copy-parent? objects %)) copies)) @@ -582,7 +587,8 @@ :action do-show-component}) (when can-update-main? {:title (tr "workspace.shape.menu.update-main") - :action do-update-component}) + :action do-update-component + :disabled update-main-loop?}) (when (and (or (not multi) same-variant?) main-instance?) {:title (tr "workspace.shape.menu.add-variant") :shortcut :create-component-variant diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs index 78b6f02a69..9e4550bee0 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs @@ -918,11 +918,12 @@ :on-close on-menu-close} [:ul {:class (stl/css-case :pill-actions-dropdown true :extended subtext)} - (for [{:keys [title action]} menu-entries] + (for [{:keys [title action disabled]} menu-entries] (when (some? title) [:li {:key title :class (stl/css :pill-actions-dropdown-item) - :on-click (partial do-action action)} + :disabled disabled + :on-click (when-not disabled (partial do-action action))} [:span {:class (stl/css :pill-actions-dropdown-item-label)} title]]))]]])])) (mf/defc component-menu* diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.scss b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.scss index 5fd8e97fc0..d22d5cbcaa 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.scss +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.scss @@ -646,6 +646,11 @@ } } +.pill-actions-dropdown-item[disabled] { + pointer-events: none; + opacity: 0.6; +} + .pill-actions-dropdown-item-label { display: block; max-inline-size: 99%;