Skip to main content
Solved

How to detect when node is deleted


Hi, my plugin is saving a list of node ids and their corresponding aspect ratios in my root node.

I want the plugin data in my root node to be updated whenever a node is deleted. Are there any events that are triggered whenever a node is deleted? If so, what event handler should I use to handle that?

Best answer by Zack_Hong

Ok, I figured out that I have to handle the documentchange event using figma.on. Then, I need to extract out the array of documentchange objects from the event and check each object to see if they are of type “DELETE” like so:

I had a hard time understanding what you meant until I saw some code examples

View original
This topic has been closed for replies.

4 replies

Gleb
  • Power Member
  • 4708 replies
  • June 26, 2023

  • Author
  • 30 replies
  • June 26, 2023

Where would the deleteChange event be handled? I tried to handle it using figma.on() but it doesn’t work


Gleb
  • Power Member
  • 4708 replies
  • June 26, 2023

There is no such thing as deleteChange:

All available events are listed above. I sent 3 links to the documentchange event so… that’s the one you should use. DocumentChange events have the following types (again, as shown in the links I sent):


  • Author
  • 30 replies
  • Answer
  • June 26, 2023

Ok, I figured out that I have to handle the documentchange event using figma.on. Then, I need to extract out the array of documentchange objects from the event and check each object to see if they are of type “DELETE” like so:

I had a hard time understanding what you meant until I saw some code examples


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings