✨ Add createComponent() helper with penpot.root guard#8694
Open
abhishek-mittal wants to merge 2 commits intopenpot:stagingfrom
Open
✨ Add createComponent() helper with penpot.root guard#8694abhishek-mittal wants to merge 2 commits intopenpot:stagingfrom
abhishek-mittal wants to merge 2 commits intopenpot:stagingfrom
Conversation
Wrap penpot.library.local.createComponent() in a PenpotUtils static helper that validates the board is already inserted into penpot.root before the call (silently fails otherwise) and documents the cross-page reparenting limitation and '/' group-separator behaviour. Closes penpot#8691 Signed-off-by: Abhishek Mittal <abhishekmittaloffice@gmail.com>
niwinz
requested changes
Mar 20, 2026
| - Fix scroll on library modal [Taiga #13639](https://tree.taiga.io/project/penpot/issue/13639) | ||
| - Update copy on penpot update message [Taiga #12924](https://tree.taiga.io/project/penpot/issue/12924) | ||
| - Fix id prop on switch component [Taiga #13534](https://tree.taiga.io/project/penpot/issue/13534) | ||
| - Fix tooltip shown on tab change [Taiga #13627](https://tree.taiga.io/project/penpot/issue/13627) |
Contributor
There was a problem hiding this comment.
I guess this additions to the CHANGES.md should not go on this PR. I suggest rebase it with staging, and ensure only the related to this PR changes are put on changelog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
PenpotUtils.createComponent()static helper that wraps the undocumentedpenpot.library.local.createComponent()Plugin API method behind a clear precondition guard.Problem
penpot.library.local.createComponent()has a non-obvious silent-failure behaviour: if the board being converted is not already a direct child ofpenpot.root, the call silently produces an empty, unnamed component instead of throwing an error. This makes plugins that create components appear to work while producing broken assets.Additionally, cross-page component creation is unsupported by the API (main instances always land on the current page), and the
"/"group-separator in component names is not documented anywhere in the public-facing MCP instructions.Changes
mcp/packages/plugin/src/PenpotUtils.ts— newcreateComponent(board, name)static method:boardis a direct child ofpenpot.rootbefore calling the API; throws a descriptiveErrorif not, with a remediation hint.@ts-ignoreto bridge the gap untilcreateComponentis added to the official TS type definitions."/"group-separator behaviour.CHANGES.md— community entry added to the## 2.15.0 (Unreleased)section.Related
Signed-off-by: Abhishek Mittal abhishekmittaloffice@gmail.com