diff --git a/CHANGES.md b/CHANGES.md index 22a8037b54..dc2012fffd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -43,6 +43,7 @@ - Fix bad behaviour on hovering and click nested artboards [Taiga #4018](https://tree.taiga.io/project/penpot/issue/4018) and [Taiga #4269](https://tree.taiga.io/project/penpot/us/4269) - Fix lang autodetect issue [Taiga #4277](https://tree.taiga.io/project/penpot/issue/4277) - Fix colorpicker does not close upon switching to Dashboard [Taiga #4408](https://tree.taiga.io/project/penpot/issue/4408) +- Fix problem with auto-width/auto-height + lock-proportions ## 1.16.0-beta diff --git a/common/src/app/common/types/modifiers.cljc b/common/src/app/common/types/modifiers.cljc index ece78a0e59..5632e8c642 100644 --- a/common/src/app/common/types/modifiers.cljc +++ b/common/src/app/common/types/modifiers.cljc @@ -443,33 +443,36 @@ (resize-modifiers (gpt/point scalex scaley) origin transform transform-inverse))) (defn change-dimensions-modifiers - [{:keys [transform transform-inverse] :as shape} attr value] - (us/assert map? shape) - (us/assert #{:width :height} attr) - (us/assert number? value) + ([shape attr value] + (change-dimensions-modifiers shape attr value nil)) - (let [{:keys [proportion proportion-lock]} shape - size (select-keys (:selrect shape) [:width :height]) - new-size (if-not proportion-lock - (assoc size attr value) - (if (= attr :width) - (-> size - (assoc :width value) - (assoc :height (/ value proportion))) - (-> size - (assoc :height value) - (assoc :width (* value proportion))))) + ([{:keys [transform transform-inverse] :as shape} attr value {:keys [ignore-lock?] :or {ignore-lock? false}}] + (us/assert map? shape) + (us/assert #{:width :height} attr) + (us/assert number? value) - width (:width new-size) - height (:height new-size) + (let [{:keys [proportion proportion-lock]} shape + size (select-keys (:selrect shape) [:width :height]) + new-size (if-not (and (not ignore-lock?) proportion-lock) + (assoc size attr value) + (if (= attr :width) + (-> size + (assoc :width value) + (assoc :height (/ value proportion))) + (-> size + (assoc :height value) + (assoc :width (* value proportion))))) - {sr-width :width sr-height :height} (:selrect shape) + width (:width new-size) + height (:height new-size) - origin (-> shape :points first) - scalex (/ width sr-width) - scaley (/ height sr-height)] + {sr-width :width sr-height :height} (:selrect shape) - (resize-modifiers (gpt/point scalex scaley) origin transform transform-inverse))) + origin (-> shape :points first) + scalex (/ width sr-width) + scaley (/ height sr-height)] + + (resize-modifiers (gpt/point scalex scaley) origin transform transform-inverse)))) (defn change-orientation-modifiers [shape orientation] diff --git a/frontend/src/app/main/data/workspace/texts.cljs b/frontend/src/app/main/data/workspace/texts.cljs index f24868f55b..7659f8b359 100644 --- a/frontend/src/app/main/data/workspace/texts.cljs +++ b/frontend/src/app/main/data/workspace/texts.cljs @@ -331,13 +331,13 @@ shape (cond-> shape (and (not-changed? shape-width new-width) (= grow-type :auto-width)) - (gsh/transform-shape (ctm/change-dimensions-modifiers shape :width new-width))) + (gsh/transform-shape (ctm/change-dimensions-modifiers shape :width new-width {:ignore-lock? true}))) shape (cond-> shape (and (not-changed? shape-height new-height) (or (= grow-type :auto-height) (= grow-type :auto-width))) - (gsh/transform-shape (ctm/change-dimensions-modifiers shape :height new-height)))] + (gsh/transform-shape (ctm/change-dimensions-modifiers shape :height new-height {:ignore-lock? true})))] shape))] @@ -364,10 +364,10 @@ (let [new-shape (cond-> shape (some? width) - (gsh/transform-shape (ctm/change-dimensions-modifiers shape :width width)) + (gsh/transform-shape (ctm/change-dimensions-modifiers shape :width width {:ignore-lock? true})) (some? height) - (gsh/transform-shape (ctm/change-dimensions-modifiers shape :height height)) + (gsh/transform-shape (ctm/change-dimensions-modifiers shape :height height {:ignore-lock? true})) (some? position-data) (assoc :position-data position-data)) diff --git a/frontend/src/app/main/data/workspace/transforms.cljs b/frontend/src/app/main/data/workspace/transforms.cljs index f6f0801572..65b9640824 100644 --- a/frontend/src/app/main/data/workspace/transforms.cljs +++ b/frontend/src/app/main/data/workspace/transforms.cljs @@ -643,8 +643,10 @@ (recursive-find-empty-parents parents)))) empty-parents - ;; Any parent whose children are moved should be deleted - (into (d/ordered-set) (find-all-empty-parents #{})) + ;; Any empty parent whose children are moved to another frame should be deleted + (if (empty? moving-shapes) + #{} + (into (d/ordered-set) (find-all-empty-parents #{}))) changes (-> (pcb/empty-changes it page-id)