mirror of
https://github.com/penpot/penpot.git
synced 2025-06-04 16:01:38 +02:00
🐛 Fix problem when resizing a group with texts with auto-width/height
This commit is contained in:
parent
c7e23c1b58
commit
8b3062be0b
3 changed files with 52 additions and 29 deletions
|
@ -97,6 +97,7 @@
|
||||||
- Fix error when drawing curves with only one point [Taiga #3282](https://tree.taiga.io/project/penpot/issue/3282)
|
- Fix error when drawing curves with only one point [Taiga #3282](https://tree.taiga.io/project/penpot/issue/3282)
|
||||||
- Fix issue with paste ordering sometimes not being respected [Taiga #3268](https://tree.taiga.io/project/penpot/issue/3268)
|
- Fix issue with paste ordering sometimes not being respected [Taiga #3268](https://tree.taiga.io/project/penpot/issue/3268)
|
||||||
- Fix problem when export/importing guides attached to frame [#1838](https://github.com/penpot/penpot/issues/1838)
|
- Fix problem when export/importing guides attached to frame [#1838](https://github.com/penpot/penpot/issues/1838)
|
||||||
|
- Fix problem when resizing a group with texts with auto-width/height [#3171](https://tree.taiga.io/project/penpot/issue/3171)
|
||||||
|
|
||||||
### :arrow_up: Deps updates
|
### :arrow_up: Deps updates
|
||||||
### :heart: Community contributions by (Thank you!)
|
### :heart: Community contributions by (Thank you!)
|
||||||
|
|
|
@ -384,6 +384,11 @@
|
||||||
(defn commit-position-data
|
(defn commit-position-data
|
||||||
[]
|
[]
|
||||||
(ptk/reify ::commit-position-data
|
(ptk/reify ::commit-position-data
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(let [ids (keys (::update-position-data state))]
|
||||||
|
(update state :workspace-text-modifiers #(apply dissoc % ids))))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
(let [position-data (::update-position-data state)]
|
(let [position-data (::update-position-data state)]
|
||||||
|
@ -404,9 +409,10 @@
|
||||||
(ptk/reify ::update-position-data
|
(ptk/reify ::update-position-data
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(if (nil? (::update-position-data-debounce state))
|
(let [state (assoc-in state [:workspace-text-modifier id :position-data] position-data)]
|
||||||
(assoc state ::update-position-data-debounce start)
|
(if (nil? (::update-position-data-debounce state))
|
||||||
(assoc-in state [::update-position-data id] position-data)))
|
(assoc state ::update-position-data-debounce start)
|
||||||
|
(assoc-in state [::update-position-data id] position-data))))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
|
|
|
@ -166,6 +166,20 @@
|
||||||
|
|
||||||
(update state :workspace-modifiers #(reduce update-shape % shapes)))))))
|
(update state :workspace-modifiers #(reduce update-shape % shapes)))))))
|
||||||
|
|
||||||
|
(defn- update-grow-type
|
||||||
|
[shape old-shape]
|
||||||
|
(let [auto-width? (= :auto-width (:grow-type shape))
|
||||||
|
auto-height? (= :auto-height (:grow-type shape))
|
||||||
|
|
||||||
|
changed-width? (not (mth/close? (:width shape) (:width old-shape)))
|
||||||
|
changed-height? (not (mth/close? (:height shape) (:height old-shape)))
|
||||||
|
|
||||||
|
change-to-fixed? (or (and auto-width? (or changed-height? changed-width?))
|
||||||
|
(and auto-height? changed-height?))]
|
||||||
|
(cond-> shape
|
||||||
|
change-to-fixed?
|
||||||
|
(assoc :grow-type :fixed))))
|
||||||
|
|
||||||
(defn- apply-modifiers
|
(defn- apply-modifiers
|
||||||
[ids]
|
[ids]
|
||||||
(us/verify (s/coll-of uuid?) ids)
|
(us/verify (s/coll-of uuid?) ids)
|
||||||
|
@ -182,27 +196,33 @@
|
||||||
(rx/of (dwu/start-undo-transaction)
|
(rx/of (dwu/start-undo-transaction)
|
||||||
(dwg/move-frame-guides ids-with-children)
|
(dwg/move-frame-guides ids-with-children)
|
||||||
(dch/update-shapes
|
(dch/update-shapes
|
||||||
ids-with-children
|
ids-with-children
|
||||||
(fn [shape]
|
(fn [shape]
|
||||||
(let [modif (get object-modifiers (:id shape))]
|
(let [modif (get object-modifiers (:id shape))
|
||||||
(gsh/transform-shape (merge shape modif))))
|
text-shape? (cph/text-shape? shape)]
|
||||||
{:reg-objects? true
|
(-> shape
|
||||||
:ignore-tree ignore-tree
|
(merge modif)
|
||||||
;; Attributes that can change in the transform. This way we don't have to check
|
(gsh/transform-shape)
|
||||||
;; all the attributes
|
(cond-> text-shape?
|
||||||
:attrs [:selrect
|
(update-grow-type shape)))))
|
||||||
:points
|
{:reg-objects? true
|
||||||
:x
|
:ignore-tree ignore-tree
|
||||||
:y
|
;; Attributes that can change in the transform. This way we don't have to check
|
||||||
:width
|
;; all the attributes
|
||||||
:height
|
:attrs [:selrect
|
||||||
:content
|
:points
|
||||||
:transform
|
:x
|
||||||
:transform-inverse
|
:y
|
||||||
:rotation
|
:width
|
||||||
:position-data
|
:height
|
||||||
:flip-x
|
:content
|
||||||
:flip-y]})
|
:transform
|
||||||
|
:transform-inverse
|
||||||
|
:rotation
|
||||||
|
:position-data
|
||||||
|
:flip-x
|
||||||
|
:flip-y
|
||||||
|
:grow-type]})
|
||||||
(clear-local-transform)
|
(clear-local-transform)
|
||||||
(dwu/commit-undo-transaction))))))
|
(dwu/commit-undo-transaction))))))
|
||||||
|
|
||||||
|
@ -483,12 +503,8 @@
|
||||||
focus (:workspace-focus-selected state)
|
focus (:workspace-focus-selected state)
|
||||||
zoom (get-in state [:workspace-local :zoom] 1)
|
zoom (get-in state [:workspace-local :zoom] 1)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
resizing-shapes (map #(get objects %) ids)
|
resizing-shapes (map #(get objects %) ids)]
|
||||||
text-shapes-ids (->> resizing-shapes
|
|
||||||
(filter #(= :text (:type %)))
|
|
||||||
(map :id))]
|
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(rx/of (dch/update-shapes text-shapes-ids #(assoc % :grow-type :fixed)))
|
|
||||||
(->> ms/mouse-position
|
(->> ms/mouse-position
|
||||||
(rx/with-latest-from ms/mouse-position-shift ms/mouse-position-alt)
|
(rx/with-latest-from ms/mouse-position-shift ms/mouse-position-alt)
|
||||||
(rx/map normalize-proportion-lock)
|
(rx/map normalize-proportion-lock)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue