Edit in GitHubLog an issue

Panel update() callback

The update() function is an optional lifecycle method in panel objects. XD calls update() whenever your panel UI content should be refreshed:

  • When the user changes the selection
  • When the user modifies a node within the current selection. This can include actions such as move, resize, changing fill color, etc.
  • When your panel is reopened after having been closed

The update function receives selection and root arguments:

Copied to your clipboard
1function update(selection, root) {
2 const { Text } = require("scenegraph");
3
4 if (!(selection.items[0] instanceof Text)) {
5 panelContainer.innerHTML = `<p>Please select a text object in the document.</p>`;
6 }
7}

Note that the example code above assumes you created a reference to the panel markup panelContainer at the global level when the panel was created.

Whenever the update function is called, it is important to get in and out as quickly as possible since it's triggered for essentially every user action in XD while your panel is open.

Copyright © 2022 Adobe. All rights reserved.