From ebb7d01bc94935c18c40ffa1b6d8017da477dd26 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Wed, 4 Feb 2026 12:44:19 +0100 Subject: [PATCH] :bug: Fix entering decimal values in dimension fields causes internal server error (#8263) --- frontend/src/app/main/data/workspace.cljs | 1 + .../app/main/data/workspace/transforms.cljs | 14 +++++++ .../sidebar/options/menus/measures.cljs | 2 +- .../logic/update_position_test.cljs | 37 +++++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 frontend/test/frontend_tests/logic/update_position_test.cljs diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 292aef0f10..9116c99024 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -1410,6 +1410,7 @@ (dm/export dwt/start-move-selected) (dm/export dwt/move-selected) (dm/export dwt/update-position) +(dm/export dwt/update-positions) (dm/export dwt/flip-horizontal-selected) (dm/export dwt/flip-vertical-selected) (dm/export dwly/set-opacity) diff --git a/frontend/src/app/main/data/workspace/transforms.cljs b/frontend/src/app/main/data/workspace/transforms.cljs index e0e076e6ba..589bd35130 100644 --- a/frontend/src/app/main/data/workspace/transforms.cljs +++ b/frontend/src/app/main/data/workspace/transforms.cljs @@ -1050,6 +1050,20 @@ :ignore-touched (:ignore-touched options) :ignore-snap-pixel true})))))))) +(defn update-positions + "Move multiple shapes to a new position." + ([ids position] (update-positions ids position nil)) + ([ids position options] + (assert (every? uuid? ids) + "expected valid coll of uuids") + (assert (map? position) "expected a valid map for `position`") + (ptk/reify ::update-positions + ptk/WatchEvent + (watch [_ _ _] + (->> ids + (map (fn [id] (update-position id position options))) + (rx/from)))))) + (defn position-shapes [shapes] (ptk/reify ::position-shapes diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs index c8a1a2ac42..e6aaa91a37 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs @@ -283,7 +283,7 @@ (if (or (string? value) (number? value)) (do (st/emit! (udw/trigger-bounding-box-cloaking ids)) - (st/emit! (udw/update-position ids {attr value}))) + (st/emit! (udw/update-positions ids {attr value}))) (st/emit! (udw/trigger-bounding-box-cloaking ids) (dwta/toggle-token {:token (first value) :attrs #{attr} diff --git a/frontend/test/frontend_tests/logic/update_position_test.cljs b/frontend/test/frontend_tests/logic/update_position_test.cljs new file mode 100644 index 0000000000..df24e4e7bf --- /dev/null +++ b/frontend/test/frontend_tests/logic/update_position_test.cljs @@ -0,0 +1,37 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS INC + +(ns frontend-tests.logic.update-position-test + (:require + [app.common.geom.rect :as grc] + [app.common.test-helpers.compositions :as ctho] + [app.common.test-helpers.files :as cthf] + [app.common.test-helpers.shapes :as cths] + [app.main.data.workspace :as dw] + [cljs.test :as t :include-macros true] + [frontend-tests.helpers.state :as ths])) + +(t/deftest test-update-positions-multiple-ids + (t/async + done + (let [file (-> (cthf/sample-file :file1) + (ctho/add-rect :rect1 :x 10 :y 20 :width 10 :height 10) + (ctho/add-rect :rect2 :x 30 :y 40 :width 10 :height 10)) + store (ths/setup-store file) + rect1 (cths/get-shape file :rect1) + rect2 (cths/get-shape file :rect2) + ids [(:id rect1) (:id rect2)] + events [(dw/update-positions ids {:x 123.45})]] + (ths/run-store + store done events + (fn [new-state] + (let [file' (ths/get-file-from-state new-state) + rect1' (cths/get-shape file' :rect1) + rect2' (cths/get-shape file' :rect2) + x1 (-> rect1' :points grc/points->rect :x) + x2 (-> rect2' :points grc/points->rect :x)] + (t/is (= 123.45 x1)) + (t/is (= 123.45 x2))))))))