Alonso Torres cb8f563bb2
🐛 Keep swapped and moved children in place when a component syncs (#12716)
* 🐛 Keep swapped and moved children in place when a component syncs

A sync resets an untouched shape of a copy to the main's geometry and the
layout then moves it back. Children the sync keeps, because they are
swapped or the user moved them, did not take the first move but did take
the second, so each sync pushed them away from their parent by the gap
between the copy and the main (e.g. a swapped icon in a copy that fills a
wider layout).

The sync now moves those children by the offset it applies to their
parent. Flex-child attributes still sync as before, so swapped children
keep their absolute position.

Closes #12657

* 🐛 Place swapped children where the swap puts them on sync and switch

A swapped child that the user never moved now goes to the top-left of the
shape it replaced, as a swap does: on a sync, the place of the main's slot
occupant; on a variant switch, the place of the new variant's occupant.
A swapped child the user moved keeps its offset inside its parent.

This stops the variant switch from leaving the swapped child at its old
position while the new variant is created at the main's size, and puts
back children that drifted before the sync fix the next time their copy
syncs.

* 🐛 Make kept children follow their parent's constraints on component sync

When a sync resets the size of a copy's shape, for example a copy root
that fills a wider layout, the layout then grows it back and moves its
children by their constraints. Children the sync keeps (moved by the
user, or swapped) only followed the parent's top-left, so with a right,
center or scale constraint they drifted on every sync, and a swapped
child with a scale constraint grew on every sync.

The sync now passes the parent's geometry before and after down the
tree, and kept children follow that change through their constraints.
Untouched swapped children also undo the change through their
constraints before they go to the swap place, so they keep their size.

The default constraint modifier returns empty modifiers instead of an
empty vector, which add-modifiers could not take.

* 🐛 Make swapped children follow their parent's constraints on switch

A variant switch only moved a swapped child by the parent's position
change. When the new variant's root had a different size, a user-moved
child with a right constraint drifted, and a scale-constrained one kept
its grown size.

The switch now applies the parent change from the old parent to the new
one through the child's constraints. An untouched swapped child then
takes the place of the shape it replaces, as a swap does.

* 🐛 Sync nested swapped copies before the copies that hold them

A swapped child is a copy of its own component, so one sync handles it
twice: once on its own, and once when the copy that holds it places it.
Each step read the shape from the data as it was before the sync, so
the step that ran last won, and the order came from the order of shape
ids. When the swapped child came last, it wrote its old size and
position back over the placement, leaving its x and selrect apart, and
a swapped child with a scale constraint grew on every sync.

The sync now visits the most deeply nested shapes first, and each step
reads the shapes as the earlier steps left them, so the placement
always comes last and builds on the child's own sync.

* 🐛 Keep moved children with a scale constraint at their size on switch

A variant switch carries the size of a child the user moved as an
override. In a copy that fills a wider layout, a child with a scale
constraint already has the size the layout gave it, so the switch
carried that size onto the new variant, created at the main's size, and
the layout then scaled it again: the child grew on every switch.

Before comparing, the switch now resizes the previous child the way its
constraints follow the change from its old parent to its new one. A
child that only grew with the layout then matches the main and is not
carried as an override.

* 🐛 Keep the content of swapped children at its size on sync and switch

When a sync or a variant switch undid the parent change on a swapped
child through its constraints, it applied the child's resize to every
shape inside it. The layout then grows the child back through its own
constraint, but its content follows its own constraints (left and top
by default), so it stayed shrunk: the shape inside a swapped icon with
a scale constraint lost most of its width on every switch.

The change of the swapped child now goes down its subtree the way a
layout update does, each shape through its own constraints.

* 🐛 Accept mixed and empty values in the layout size constraints menu

With several shapes or a group selected, the sidebar merges the layout
item attributes and tokens of the shapes: nil when a shape lacks one,
:multiple when they differ. The props schema of layout-size-constraints*
only accepted the values of a single shape, so selecting such shapes
with fill sizing raised "invalid props".

The schema now accepts nil and :multiple, as the numeric inputs those
values go to do.

* ♻️ Share the swapped child follow-parent step between sync and switch

The component sync and the variant switch both make a swapped child and
its children follow the parent change through their constraints and then
move them to the swap place. Both now use generate-follow-parent, so the
two paths stay the same. The helper that writes geometry without marking
it touched is renamed to update-geometry-untouched.

Adds a test for a swapped child without absolute position in a slot
without layout, and fixes the test comments on why constraints are set
again after a swap.
2026-10-29 17:30:16 +01:00
2026-09-25 11:11:44 +02:00
2026-10-29 15:43:06 +01:00
2026-09-23 18:53:25 +02:00
2026-10-29 15:43:06 +01:00
2026-10-29 15:43:06 +01:00
2026-10-29 15:43:06 +01:00
2021-11-15 09:54:36 -05:00
2026-10-29 15:43:06 +01:00
2026-10-29 15:43:06 +01:00
2026-10-29 15:43:06 +01:00
2026-10-29 15:43:06 +01:00
2026-10-29 15:43:06 +01:00
2020-08-11 10:11:23 +02:00
2025-01-22 15:46:23 +01:00
2026-07-22 14:18:51 +02:00
2017-03-06 18:42:58 +01:00
2026-10-19 20:10:20 +02:00
2026-10-29 14:09:54 +00:00
2026-10-19 20:10:20 +02:00
2025-06-02 12:09:20 +02:00
2023-11-15 10:55:39 +01:00
2026-10-29 15:43:06 +01:00
2026-10-29 15:43:06 +01:00
2026-06-09 18:48:03 +02:00
2020-08-05 11:19:34 +02:00

Verified DPG Penpot Community Managed with Taiga.io Gitpod ready-to-code

Website • User Guide • Learning Center • Community

Youtube • Peertube • Linkedin • Instagram • Mastodon • Bluesky • X

Penpot video

Penpot is the open-source design platform for teams that build digital products at scale.

Penpot’s key strength lies in giving you full ownership of your design infrastructure. Built on open source and designed for self-hosting, it puts teams in complete control of their design environment supporting strict compliance and governance requirements. Whether used in the browser or deployed on your own servers, Penpot works with open standards like SVG, CSS, HTML, and JSON.

Real-time collaboration strengthens this foundation, helping teams scale and bring design closer to the product through top-tier capabilities. Additionally, developers feel at home using Penpot, because design is expressed as code, enabling a direct translation and shipping products faster.

Best-in-class native Design Tokens provide a single source of truth between design and development. They ensure consistency, improve collaboration, and make it easier to manage complex design systems.

The MCP server takes it further by enabling multi-directional workflows between design and code. A powerful open API and plugin system makes the workspace programmable, enabling automation, AI-driven workflows, and integrations with the tools and systems you already use.

With CSS Grid and Flex Layout, teams can design responsive interfaces that behave like real code from the start.

Combined, these features turn Penpot into a full-stack design platform for building scalable design systems and fully integrated product development processes.

If your organization is scaling and needs extra support, we’re here to help. Talk to us

Table of contents

Why Penpot

Penpot connects design, code, and AI workflows through a code-based approach, making designs readable by developers and AI via the MCP server. This approach helps teams ship what’s actually designed and manage design systems at scale with powerful design tokens. As a self-hosted, open-source and real-time collaboration platform, Penpot offers full flexibility, security, and ownership without vendor lock-in. Learn more about why Penpot is the platform for your team.

Plugin system

Penpot plugins let you expand the platform's capabilities, give you the flexibility to integrate it with other apps, and design custom solutions.

Designed for developers

Penpot was built to serve both designers and developers and create a fluid design-code process. You have the choice to enjoy real-time collaboration or play "solo".

Inspect mode

Work with ready-to-use code and make your workflow easy and fast. The inspect tab gives instant access to SVG, CSS and HTML code.

Integrations

Penpot offers integration into the development toolchain, thanks to its support for webhooks and an API accessible through access tokens.

Building Design Systems: design tokens, components and variants

Penpot brings design systems to code-minded teams: a single source of truth with native Design Tokens, Components, and Variants for scalable, reusable, and consistent UI across projects and platforms.

Penpot Design Systems

Getting started

Penpot is the only design & prototype platform that is deployment agnostic. You can use it in our SAAS or deploy it anywhere.

Learn how to install it with Docker, Kubernetes, Elestio or other options on our website.

Penpot Enterprise

Penpot Enterprise is our paid plan for organizations that need to scale their design work across multiple teams with advanced governance, security, and administration. Manage teams and access from a centralized Admin Console, configure advanced permissions, and connect your identity provider through SSO. Available for cloud and self-hosted environments, it combines enterprise controls with Penpot’s open-source foundation and open standards.

2

Community

We love the Open Source software community. Contributing is our passion and if it’s yours too, participate and improve Penpot. All your designs, code and ideas are welcome!

Want to go a step further? Become a Penpot Ambassador and help grow the Penpot community in your region while contributing to a global, open design ecosystem.

If you need help or have any questions; if you’d like to share your experience using Penpot or get inspired; if you’d rather meet our community of developers and designers, join our Community!

Categories include:

Pentpot Community

Code of Conduct

Anyone who contributes to Penpot, whether through code, in the community, or at an event, must adhere to the code of conduct and foster a positive and safe environment.

Contributing

Any contribution will make a difference to improve Penpot. How can you get involved?

Choose your way:

To find (almost) everything you need to know on how to contribute to Penpot, refer to the contributing guide.

Penpot hub

Resources

You can ask and answer questions, have open-ended conversations, and follow along on decisions affecting the project.

💾 Documentation

🚀 Getting Started

✏️ Tutorials

🏘️ Architecture

📚 Dev Diaries

🧑‍🏫​ UI Design Course

License

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.

Copyright (c) KALEIDOS SUBSIDIARY SL

Penpot is a Kaleidos’ open source project

Description
Penpot: The open-source design tool for design and code collaboration
Readme MPL-2.0 515 MiB
Languages
Clojure 73.4%
JavaScript 7%
Rust 6.8%
TypeScript 5.8%
SCSS 3.3%
Other 3.6%