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:

The update function receives selection and root arguments:

function update(selection, root) {
  const { Text } = require("scenegraph");

  if (!(selection.items[0] instanceof Text)) {
    panelContainer.innerHTML = `<p>Please select a text object in the document.</p>`;
  }
}

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.