mirror of
https://github.com/penpot/penpot.git
synced 2026-11-20 09:00:49 +00:00
On the SVG renderer, a text is measured only when its text properties change or when it has no position-data. A component copy with overridden text content keeps its own position-data. If its main changes while the page is closed, the copy takes the main's size, and nothing measures it when the page opens. It keeps the main's height, so its flex siblings overlap the extra lines. When a page opens, each auto-width or auto-height text with overridden content on a copy starts in a :check phase and gets one hidden HTML measurement. In :check, the result is written (size and position-data) only if the size differs by more than 1px on the axis the text grows on. Otherwise nothing is written, though the text modifier is still cleaned. The phase is then dropped, so later measurements work as before. A copy with no position-data skips the check and is measured and committed as usual. The new dwt/text-size-drifted? holds the 1px rule. It ignores an axis that fills its layout parent, because the layout sets that size and the check would otherwise find drift on every open. The 1px tolerance matches the WebGL page-load check. SVG stores whole pixels, rounded up, so smaller gaps are only rounding. A finer tolerance would rewrite the same texts each time a page opened. Each content-overridden auto-grow copy costs one extra measurement per page open. Tests: frontend-tests.data.workspace-texts-test covers text-size-drifted? for sub-pixel and exact 1px gaps, the growing axis only, and fill axes. frontend-tests.ui.viewport-texts-html-test covers which copies start in :check, the drifted, matching and unmeasurable cases, and the 1px commit when no phase is set. Known limit: the heal commits like any SVG measurement, so it adds to the user's last undo entry. Relates to #12721 Relates to #13065