From 4ef01749177ff3cec74d355b1c195e87582fa0b4 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Sat, 31 Oct 2026 13:18:11 +0100 Subject: [PATCH] :sparkles: Disable update main when it would nest a component in itself Update main from a copy that holds its own component, or a component whose main holds it, changes nothing, because the result would nest the component inside itself. The menus still offered it. Disable the entry for such a copy, with the same check the update applies, in the canvas context menu and in the design tab's component menu, which now renders disabled entries as the context menu does. The full rebuilt frontend passes 1799 tests / 16286 assertions; backend passes 1838 / 9293 and exporter 16 / 40. Frontend formatting passes and lint reports no errors for the changed files. AI-assisted-by: claude-opus-5-5 --- frontend/src/app/main/ui/workspace/context_menu.cljs | 1 + .../src/app/main/ui/workspace/sidebar/assets/common.cljs | 8 +++++++- .../ui/workspace/sidebar/options/menus/component.cljs | 5 +++-- .../ui/workspace/sidebar/options/menus/component.scss | 5 +++++ 4 files changed, 16 insertions(+), 3 deletions(-) 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%;