From f0680cf5f8790a5e11682daad91cf96f4d108eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Torr=C3=B3?= Date: Mon, 7 Sep 2026 09:53:45 +0200 Subject: [PATCH] :bug: Handle empty variant options (#11499) * :bug: Handle empty variant options * :bug: Disable variant value select when there are no options --- .../workspace/sidebar/options/menus/component.cljs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 d2a8ff1c90..5036ad87a7 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 @@ -290,14 +290,18 @@ get-components-with-duplicated-variant-props-and-values (map :main-instance-id))) +(defn- get-variant-option + [val] + {:id val + :label (if (str/blank? val) (str "(" (tr "labels.empty") ")") val)}) + (defn- get-variant-options "Get variant options for a given property name" [prop-name prop-vals] (->> (filter #(= (:name %) prop-name) prop-vals) first :value - (mapv (fn [val] {:id val - :label (if (str/blank? val) (str "(" (tr "labels.empty") ")") val)})))) + (mapv get-variant-option))) (mf/defc component-variant-property* [{:keys [pos prop options on-prop-name-blur on-prop-value-change on-reorder]}] @@ -527,8 +531,12 @@ (for [[pos prop] (map-indexed vector props-first)] (let [mixed-value? (not-every? #(= (:value prop) (:value (get % pos))) properties) base-options (get options-by-name (:name prop)) + no-options? (empty? base-options) boolean-pair (ctv/find-boolean-pair (mapv :id base-options)) options (cond-> base-options + no-options? + (conj (get-variant-option (:value prop))) + mixed-value? (conj {:id mixed-label :label mixed-label :dimmed true}))] @@ -549,6 +557,7 @@ [:> select* {:default-selected (if mixed-value? mixed-label (:value prop)) :options options :empty-to-end true + :disabled no-options? :on-change (partial switch-component pos) :key (str (:value prop) "-" key)}]])]))]