From 22ded62000854dc1ae4315dc951c84df84e36d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Thu, 26 Jan 2023 11:10:07 +0100 Subject: [PATCH] :bug: Fix paths not flagged as modified when resized --- CHANGES.md | 1 + common/src/app/common/pages/changes.cljc | 4 ++++ .../src/app/main/data/workspace/modifiers.cljs | 17 ++++++++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f6cbaf41d..04fd33dfd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -64,6 +64,7 @@ - Fix text in custom font is not at the expected position at export [Taiga #4394](https://tree.taiga.io/project/penpot/issue/4394) - Fix unneeded popup when updating local components [Taiga #4430](https://tree.taiga.io/project/penpot/issue/4430) - Fix multiuser - "Shadow" element is not updating immediately [Taiga #4709](https://tree.taiga.io/project/penpot/issue/4709) +- Fix paths not flagged as modified when resized [Taiga #4742](https://tree.taiga.io/project/penpot/issue/4742) ### :heart: Community contributions by (Thank you!) diff --git a/common/src/app/common/pages/changes.cljc b/common/src/app/common/pages/changes.cljc index e8abf30fb..2e58f5440 100644 --- a/common/src/app/common/pages/changes.cljc +++ b/common/src/app/common/pages/changes.cljc @@ -387,6 +387,10 @@ is-geometry? (and (or (= group :geometry-group) (and (= group :content-group) (= (:type shape) :path))) (not (#{:width :height} attr))) ;; :content in paths are also considered geometric + ;; TODO: the check of :width and :height probably may be removed + ;; after the check added in data/workspace/modifiers/check-delta + ;; function. Better check it and test toroughly when activating + ;; components-v2 mode. shape-ref (:shape-ref shape) root-name? (and (= group :name-group) (:component-root? shape)) diff --git a/frontend/src/app/main/data/workspace/modifiers.cljs b/frontend/src/app/main/data/workspace/modifiers.cljs index de4782c4a..dd84afb43 100644 --- a/frontend/src/app/main/data/workspace/modifiers.cljs +++ b/frontend/src/app/main/data/workspace/modifiers.cljs @@ -79,15 +79,22 @@ (gpt/point (- (gsh/left-bound transformed-shape) (gsh/left-bound transformed-root)) (- (gsh/top-bound transformed-shape) (gsh/top-bound transformed-root)))) - ;; There are cases in that the coordinates change slightly (e.g. when - ;; rounding to pixel, or when recalculating text positions in different - ;; zoom levels). To take this into account, we ignore movements smaller - ;; than 1 pixel. distance (if (and shape-delta transformed-shape-delta) (gpt/distance-vector shape-delta transformed-shape-delta) (gpt/point 0 0)) - ignore-geometry? (and (< (:x distance) 1) (< (:y distance) 1))] + selrect (:selrect shape) + transformed-selrect (:selrect transformed-shape) + + ;; There are cases in that the coordinates change slightly (e.g. when rounding + ;; to pixel, or when recalculating text positions in different zoom levels). + ;; To take this into account, we ignore movements smaller than 1 pixel. + ;; + ;; When the change is a resize, also has a transformation that may have the + ;; shape position unchanged. But in this case we do not want to ignore it. + ignore-geometry? (and (and (< (:x distance) 1) (< (:y distance) 1)) + (mth/close? (:width selrect) (:width transformed-selrect)) + (mth/close? (:height selrect) (:height transformed-selrect)))] [root transformed-root ignore-geometry?]))