Select the parent element from panel

Is it not possible to select the parent element from the panel? When I run the following code from a click handler I get an error:

Plugin Error: Cannot select node outside the current edit context’s scope: Group (‘Main’)

I’ve tried all three of these:

    async function selectParentElement(sceneNode) {
        const { selection } = require("scenegraph");

    	if (sceneNode && sceneNode.parent) {

    		try {

    			editDocument( async() => {
    				selection.items = [sceneNode.parent];
    			})
    		}
    		catch(error) {
    			console.log("Error:" + error.stack);
    		}
    	}
    }


function selectParentElement(sceneNode) {
    const { selection } = require("scenegraph");

	if (sceneNode && sceneNode.parent) {

		try {

			editDocument(() => {
				selection.items = [sceneNode.parent];
			})
		}
		catch(error) {
			console.log("Error:" + error.stack);
		}
	}
}


function selectParentElement(sceneNode) {
    const { selection } = require("scenegraph");

	if (sceneNode && sceneNode.parent) {

		try {
			selection.items = [sceneNode.parent];
		}
		catch(error) {
			console.log("Error:" + error.stack);
		}
	}
}

As per https://adobexdplatform.com/plugin-docs/reference/core/edit-context.html?h=edit%20context, you can only select the item or its children.

1 Like