diff --git a/frontend/src/app/main/ui/workspace/tokens/core.cljs b/frontend/src/app/main/ui/workspace/tokens/core.cljs index 35c0c7580..30de64021 100644 --- a/frontend/src/app/main/ui/workspace/tokens/core.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/core.cljs @@ -94,15 +94,16 @@ "Removes `attributes` that match `token` for `shape-ids`. Doesn't update shape attributes." - [{:keys [attributes shape-ids] :as _props}] + [{:keys [attributes token shape-ids] :as _props}] (ptk/reify ::unapply-token ptk/WatchEvent (watch [_ _ _] (rx/of - (dch/update-shapes - shape-ids - (fn [shape] - (update shape :applied-tokens remove-keys attributes))))))) + (let [remove-token #(wtt/remove-attributes-for-token-id attributes (:id token) %)] + (dch/update-shapes + shape-ids + (fn [shape] + (update shape :applied-tokens remove-token)))))))) (defn toggle-token [{:keys [token-type-props token shapes] :as _props}] @@ -115,6 +116,7 @@ (if unapply-tokens? (rx/of (unapply-token {:attributes attributes + :token token :shape-ids shape-ids})) (rx/of (apply-token {:attributes attributes diff --git a/frontend/test/token_tests/logic/token_actions_test.cljs b/frontend/test/token_tests/logic/token_actions_test.cljs index 1c986799a..f07affdae 100644 --- a/frontend/test/token_tests/logic/token_actions_test.cljs +++ b/frontend/test/token_tests/logic/token_actions_test.cljs @@ -206,7 +206,7 @@ (t/is (= (:rx rect-2') 24))))))))) (t/deftest test-toggle-token-mixed - (t/testing "should unapply token if one of the selected items has the token applied" + (t/testing "should unapply given token if one of the selected items has the token applied" (t/async done (let [file (-> (setup-file) @@ -215,6 +215,7 @@ rect-1 (cths/get-shape file :rect-1) rect-2 (cths/get-shape file :rect-2) events [(wtc/toggle-token {:shapes [rect-1 rect-2] + :token (toht/get-token file :token-1) :token-type-props {:attributes #{:rx :ry}}})]] (tohs/run-store-async store done events