mirror of
https://github.com/penpot/penpot.git
synced 2026-11-23 19:00:36 +00:00
🐛 Push no typography a copy text's own styles drop
A copy text that overrides a typography unit, such as its font family, drops a typography its main applies, without a typography override. When update main pushes that text into the main, it keeps the same reference, yet the push authored the missing reference as a typography override. The pushed text now leaves out the typography group when its own text overrides drop the reference; a typography that differs on its own is still authored. Tests: pushing-a-text-authors-no-typography-its-own-styles-drop and the regression program updating-a-main-from-a-switched-copy-keeps-the-text-overrides-it-pushes. Full common suite: 2348 tests, 1 failure, the known 20-program coverage flake (library-redo reached by one program; the property passes). Benchmark (scripts/bench-components, ms, lower 2.5% quantile): | :world | :baseline | :now | :mean | :ratio | |------------------------------------+-----------+--------+---------+--------| | deepest-edit-through-three-levels | 35.215 | 19.02 | 19.838 | 0.54 | | edit-through-a-chain-of-dependents | 68.931 | 37.452 | 39.34 | 0.54 | | library-update-into-copies | 83.083 | 45.852 | 48.286 | 0.55 | | main-edit-among-many-shapes | 4.837 | 1.893 | 2.076 | 0.39 | | main-edit-into-10-copies | 1.79 | 1.068 | 1.092 | 0.6 | | main-edit-into-100-copies | 15.415 | 10.287 | 10.57 | 0.67 | | main-edit-into-1000-copies | 153.086 | 97.173 | 105.333 | 0.63 | | variant-switch-into-copies | 32.052 | 20.618 | 21.363 | 0.64 | AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
0d09f13cb0
commit
99102d2236
@ -1238,8 +1238,13 @@
|
||||
(not= (get shape attr) (get reference attr)))
|
||||
group))))
|
||||
updatable-attrs)
|
||||
overrides (when text? (txt/text-overrides (:touched shape)))
|
||||
;; the copy's own styles drop a typography they do not all come with
|
||||
dropped? (and (not (contains? overrides :text-content-typography))
|
||||
(some #(contains? overrides %) txt/typography-units))
|
||||
text-groups (when text?
|
||||
(txt/override-groups (:content reference) (:content shape)))
|
||||
(cond-> (txt/override-groups (:content reference) (:content shape))
|
||||
dropped? (disj :text-content-typography)))
|
||||
groups (cond-> (into groups text-groups)
|
||||
(seq text-groups) (conj :content-group))]
|
||||
(cond-> shape
|
||||
|
||||
@ -1814,6 +1814,13 @@
|
||||
:ops [[:variant-property 0 0 0 0] [:switch 3] [:style 25 7 1] [:combine 0] [:switch 1]
|
||||
[:make-variant 19] [:switch 26]]}))))
|
||||
|
||||
(t/deftest updating-a-main-from-a-switched-copy-keeps-the-text-overrides-it-pushes
|
||||
(t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout nil :variant-diff false
|
||||
:layout-item-margins false :grid-square false :rich-variants true
|
||||
:layout-children false :grid-empty false :layout-copies true :text true}]
|
||||
:ops [[:combine 0] [:switch 10] [:text-style 6 0 1] [:text-style 12 8 1]
|
||||
[:edit 3 0 1 1] [:update-main 3]]}))))
|
||||
|
||||
(t/deftest random-variant-compositions
|
||||
(let [coverage (atom {})
|
||||
failure (atom nil)]
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
[app.common.test-helpers.ids-map :as thi]
|
||||
[app.common.test-helpers.normalize :as thn]
|
||||
[app.common.test-helpers.shapes :as ths]
|
||||
[app.common.test-helpers.texts :as thtx]
|
||||
[app.common.test-helpers.variants :as thv]
|
||||
[app.common.types.component :as ctk]
|
||||
[app.common.types.container :as ctn]
|
||||
@ -1073,6 +1074,18 @@
|
||||
(t/is (= (thn/normalize-file (tm/file edited))
|
||||
(thn/normalize-file (tm/file (r/step updated (n/undo))))))))
|
||||
|
||||
(t/deftest pushing-a-text-authors-no-typography-its-own-styles-drop
|
||||
(let [_ (thi/new-id! :title)
|
||||
reference {:type :text :content (thtx/content [[["Hello" {:typography :title :size 22}]]])}
|
||||
text {:type :text :content (thtx/content [[["Hello" {:family "Inter" :size 22}]]])}
|
||||
author #'cll/author-pushed-content]
|
||||
;; a family of its own drops the reference; the copy holds no typography
|
||||
(t/is (= #{:content-group :text-content-family}
|
||||
(:touched (author (assoc text :touched #{:content-group :text-content-family}) reference))))
|
||||
;; without one, the missing reference is a difference the push authors
|
||||
(t/is (= #{:content-group :text-content-family :text-content-typography}
|
||||
(:touched (author (assoc text :touched #{}) reference))))))
|
||||
|
||||
(t/deftest swapping-back-inherits-the-new-positions-content-overrides
|
||||
(let [initial (tm/make-situation (setup))
|
||||
child-id (first (:shapes (tm/resolve-shape initial :card-star)))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user