From b7ee5d30ec8595100a915b185b4732ec6bde0fcb Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 19 Nov 2026 09:46:31 +0100 Subject: [PATCH] :bug: Switch a variant set's layout between flex and grid in place A variant set board or a variant main that already had a layout kept it when the user picked the other type (Shift+A / Ctrl+Shift+A or the context menu). `create-layout` sends a shape with a layout to `create-layout-from-selection`, which refused any selection holding a variant container or a variant, before reaching its in-place branch. The refusal now applies only when the selection would be wrapped in a new board; a single shape with a layout switches it in place. Found by the components Qase run (PENPOT-2422). Test: `create-layout-switches-a-variant-container-layout`, `create-layout-switches-a-variant-main-layout` (groups-test). AI-assisted-by: claude-opus-5-5 --- .../app/main/data/workspace/shape_layout.cljs | 4 ++- .../frontend_tests/logic/groups_test.cljs | 34 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/main/data/workspace/shape_layout.cljs b/frontend/src/app/main/data/workspace/shape_layout.cljs index 1011722ae3..81eba4a869 100644 --- a/frontend/src/app/main/data/workspace/shape_layout.cljs +++ b/frontend/src/app/main/data/workspace/shape_layout.cljs @@ -209,7 +209,9 @@ new-shape-id (uuid/next) undo-id (js/Symbol)] - (if (or has-variant? has-container? crosses-set?) + ;; Only a selection that gets wrapped in a new board is refused; a + ;; shape that already has a layout switches it in place. + (if (and (not has-layout?) (or has-variant? has-container? crosses-set?)) (rx/empty) (rx/concat (rx/of (dwu/start-undo-transaction undo-id)) diff --git a/frontend/test/frontend_tests/logic/groups_test.cljs b/frontend/test/frontend_tests/logic/groups_test.cljs index f8bd0c80ae..7cc835dbfa 100644 --- a/frontend/test/frontend_tests/logic/groups_test.cljs +++ b/frontend/test/frontend_tests/logic/groups_test.cljs @@ -664,6 +664,40 @@ (t/is (= (:id board) (:parent-id main'))))) :commits commits)))) +(t/deftest create-layout-switches-a-variant-container-layout + (t/async + done + (let [file (-> (variant-file) + (cths/update-shape :variant :layout :flex)) + commits (atom [])] + (run file + [(dws/select-shapes (d/ordered-set (cthi/id :variant))) + (dwsl/create-layout :grid)] + done + (fn [state] + (let [board' (cths/get-shape (ths/get-file-from-state state) :variant)] + (t/is (pos? (count @commits))) + (t/is (ctl/grid-layout? board')) + (t/is (ctk/is-variant-container? board')))) + :commits commits)))) + +(t/deftest create-layout-switches-a-variant-main-layout + (t/async + done + (let [file (-> (variant-file) + (cths/update-shape :root1 :layout :grid)) + commits (atom [])] + (run file + [(dws/select-shapes (d/ordered-set (cthi/id :root1))) + (dwsl/create-layout :flex)] + done + (fn [state] + (let [main' (cths/get-shape (ths/get-file-from-state state) :root1)] + (t/is (pos? (count @commits))) + (t/is (ctl/flex-layout? main')) + (t/is (ctk/is-variant? main')))) + :commits commits)))) + (t/deftest create-layout-of-one-nested-child-commits (t/async done