You’re adding something to the scenegraph in an async operation – you must make sure that there’s a complete promise chain returned to the menu handler in order to make changes to the scenegraph. If not, XD locks it down immediately after invoking your plugin.
module.exports = {
commands: {
someCommand: function(selection) {
return new Promise((resolve, reject) => {
// you can make changes as long as this promises is neither resolved nor rejected
// once resolved, the scenegraph becomes locked to changes from code
// if rejected, changes to the scenegraph will be undone completely
});
}
}
};