Skip to content

🐛 Token remap preserves child component sync after renaming a token group#9566

Open
RenzoMXD wants to merge 2 commits into
penpot:developfrom
RenzoMXD:fix/9495-token-remap-touched-copy
Open

🐛 Token remap preserves child component sync after renaming a token group#9566
RenzoMXD wants to merge 2 commits into
penpot:developfrom
RenzoMXD:fix/9495-token-remap-touched-copy

Conversation

@RenzoMXD
Copy link
Copy Markdown
Contributor

Summary

Fixes #9495: after renaming a token group and clicking REMAP, applying a new token to the main component no longer propagates to its copies (child components).

Root cause

remap-tokens (frontend/src/app/main/data/workspace/tokens/remapping.cljs) updates applied-token references on shapes via pcb/update-shapes — but without :ignore-touched true. On a copy shape, set-shape-attr then sees in-copy? = true and a non-empty diff on :applied-tokens, so it flips the corresponding sync group (e.g. :fill-group) into the copy's :touched set.

Once a sync group is touched, the next main→copy sync skips that group in generate-update-tokens (common/src/app/common/logic/libraries.cljc:1647), and the copy is silently left behind. This matches the bug report exactly: Step 5 works (initial apply was not touched), Step 7 fails (the copy is now touched on :fill-group).

Fix

Pass {:ignore-touched true} to the pcb/update-shapes call so REMAP — a refactor, not a user override — does not mark copies as touched.

To keep the fix testable, the change-building portion of remap-tokens is extracted into a pure build-remap-changes function; the ptk event becomes a thin wrapper around it.

Tests

Three new tests in frontend/test/frontend_tests/tokens/logic/token_remapping_test.cljs:

  1. test-remap-tokens-finds-both-main-and-copy — scan finds the applied-token on both main and copy.
  2. test-remap-tokens-does-not-touch-copy — after REMAP, the copy's :touched set does not contain :fill-group.
  3. test-remap-preserves-copy-sync-of-later-token-apply — end-to-end regression mirroring Steps 1–8 of the issue: build file → rename group → REMAP → apply colors.secondary to main → run component sync → assert copy reflects colors.secondary.

All three tests were verified to fail without the fix and pass with it. The pre-fix E2E failure was:

expected: (= "colors.secondary" (get-in copy-child' [:applied-tokens :fill]))
  actual: (not (= "colors.secondary" "colors.primary"))

— exactly the user-visible symptom in the issue.

Test plan

@madalenapmelo-kp
Copy link
Copy Markdown
Contributor

Thanks for your contribution! We've received your pull request and assigned it for review. We have a lot on our plate right now, so it may take us a little while to get to it but we appreciate your patience and will be in touch as soon as we can!

…495-token-remap-touched-copy

# Conflicts:
#	CHANGES.md
@RenzoMXD
Copy link
Copy Markdown
Contributor Author

Hi, @niwinz
Could you review my PR please? Plz let me know what to update. Thanks.

@niwinz niwinz assigned hirunatan and unassigned niwinz May 13, 2026
@niwinz niwinz added this to Main May 13, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in Main May 13, 2026
@niwinz niwinz added this to the 2.16.0 milestone May 13, 2026
@niwinz niwinz added the community contribution Submitted by a contributor outside the core Penpot team label May 13, 2026
@niwinz niwinz moved this from Backlog to Tech Review in Main May 13, 2026
@niwinz niwinz modified the milestones: 2.16.0, 2.17.0 May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community contribution Submitted by a contributor outside the core Penpot team

Projects

Status: Tech Review

Development

Successfully merging this pull request may close these issues.

Child component with a token applied is not updated after renaming tokens group

4 participants