figma / code-snippet-editor-plugin

Translate component variants, properties, and more into dynamic code snippets for your design system.
https://www.figma.com/community/plugin/1311777988952403297/code-snippet-editor
MIT License
126 stars 11 forks source link

Undo from main canvas also does undo for code typed into inspect code snippet instead. #16

Closed mikeysouthwell closed 5 months ago

mikeysouthwell commented 5 months ago

Posisble bug?

If you click on undo in Figma in the main canvas with DevMode off and the Inspect flyout menu minimised, it still undoes the changes that were made to your code snippet, instead of the changes you made on the canvas before opening the Code Snippet Editor.

The intention from the user should be the undo the recent changes on the canvas not from the Code Snippet Editor.

jake-figma commented 5 months ago

This is a limitation of the Figma Plugin API. Undo is essentially undoing the setting of the template plugin data on the node.

Saving a template on the node is the equivalent of changing any node property in that it is treated like a change that can be undone with the Figma "undo" command.

Im impressed that you noticed this so quickly! One quirk of plugins thats come up a few times but makes sense when you understand what it is under the hood.