Allow editing of specialNode children

trying to edit the children of a booleanGroup throws an error.

needed:
a booleanGroup which contains at least one rectangle

example code:
(can be copied into the increaseRectangle example https://adobexdplatform.com/plugin-docs/tutorials/quick-start-panel/)

    let i = selection.items[0];
    if(i.constructor.name == "BooleanGroup"){
        console.log(i);
        i.children.forEach(function(c){
            console.log(c);
            if(c.constructor.name == "Rectangle"){
                  let radii = c.cornerRadii;
                  console.log(radii);
                  radii.topLeft = 10;
                  c.cornerRadii = radii; //this throws an error
            }
        });
    }

developer console output:

Plugin Error: Plugin made a change outside the current edit context
at convertPluginErrorToString (plugins/PluginErrorUtil.js:1:198)
at internalFormatPluginError (plugins/PluginErrorUtil.js:1:1073)
at internalReportPluginError (plugins/PluginErrorUtil.js:1:1180)
at Object.reportPluginError (plugins/PluginErrorUtil.js:1:1612)
at r (plugins/ScenegraphGuard.js:1:550)
at Object.checkChange (plugins/ScenegraphGuard.js:1:1067)
at Object.EventEmitter._emitEvent (third_party/events.js:1:1178)
at Object.EventEmitter.emit (third_party/events.js:1:1668)
at Rectangle.Group.notifyChanged (lib/scenegraph/GroupExtension.js:1:842)
at Rectangle.<anonymous> (plugins/ScenegraphWrappers.js:1:17976)
at Rectangle.<anonymous> (plugins/ScenegraphWrappers.js:1:2622)
at C:\Users\tp\AppData\Local\Packages\Adobe.CC.XD_adky2gkssdxte\LocalState\develop\17b0abca\main.js:194:37
at plugins/WrapperList.js:1:378
at LinkedList.forEach (lib/LinkedList.js:1:1534)
at ReadOnlyList.forEach (lib/ReadOnlyList.js:1:282)
at WrapperList.forEach (plugins/WrapperList.js:1:354)
at C:\Users\tp\AppData\Local\Packages\Adobe.CC.XD_adky2gkssdxte\LocalState\develop\17b0abca\main.js:188:24
at Object.execScenegraphEdit (plugins/ScenegraphGuard.js:1:4431)
at plugins/ApplicationWrapper.js:1:4185
at b.increaseRectangleSize (C:\Users\tp\AppData\Local\Packages\Adobe.CC.XD_adky2gkssdxte\LocalState\develop\17b0abca\main.js:176:5)
at uxp://uxp-internal/home/ubuntu/jenkins/workspace/Torq/torq-native/release-3.1.0/build/modules_gen/domjs/src/js/domjs_scripts.js:322:893
at j (uxp://uxp-internal/home/ubuntu/jenkins/workspace/Torq/torq-native/release-3.1.0/build/modules_gen/domjs/src/js/domjs_scripts.js:322:785)
at g (uxp://uxp-internal/home/ubuntu/jenkins/workspace/Torq/torq-native/release-3.1.0/build/modules_gen/domjs/src/js/domjs_scripts.js:322:390)
at f (uxp://uxp-internal/home/ubuntu/jenkins/workspace/Torq/torq-native/release-3.1.0/build/modules_gen/domjs/src/js/domjs_scripts.js:322:192)
at k (uxp://uxp-internal/home/ubuntu/jenkins/workspace/Torq/torq-native/release-3.1.0/build/modules_gen/domjs/src/js/domjs_scripts.js:322:1097)
at Object.l [as dispatchNativeEvent] (uxp://uxp-internal/home/ubuntu/jenkins/workspace/Torq/torq-native/release-3.1.0/build/modules_gen/domjs/src/js/domjs_scripts.js:322:1468)
at b.value (uxp://uxp-internal/home/ubuntu/jenkins/workspace/Torq/torq-native/release-3.1.0/build/modules_gen/domjs/src/js/domjs_scripts.js:222:1270)
at i (uxp://uxp-internal/home/ubuntu/jenkins/workspace/Torq/torq-native/release-3.1.0/build/modules_gen/domjs/src/js/domjs_scripts.js:322:533)
at f (uxp://uxp-internal/home/ubuntu/jenkins/workspace/Torq/torq-native/release-3.1.0/build/modules_gen/domjs/src/js/domjs_scripts.js:322:249)
at k (uxp://uxp-internal/home/ubuntu/jenkins/workspace/Torq/torq-native/release-3.1.0/build/modules_gen/domjs/src/js/domjs_scripts.js:322:1097)

expected behaviour
change of the child item

behaviour
error and reverting/undo of the changes

suggestion
it would be really useful if this was allowed.
as children of groups can be edited, this seems inconsistent.

hello @tp_up,

Thanks for bringing this up. Unfortunately, XD currently has a limitation around edit context (https://adobexdplatform.com/plugin-docs/reference/core/edit-context.html?h=edit%20context). This prohibits plugins from making edits to children of special nodes, such as repeat grids, mask group, boolean group, and linked graphic. I know the link above does not specifically mention boolean group. However, boolean group is one of the noted special nodes. We will update the docs to make it more clear. Please let me know if you have any questions.

But I believe it will work if you select one of the BooleanGroup members, since then the BooleanGroup node becomes the edit context root. It may even work if you select the BooleanGroup itself?

ok thank you for clarifying that.
is that something which will change in the future or are there specific reasons why this should not be allowed?
i understand that from a users perspective changes should only happen to the selected objects, but it would be useful for our use case if we could change all types of children.

1 Like

indeed, it only works when a memeber of the BooleanGroup is selected, not when the BooleanGroup itself is selected.

i might try if ungroup() group() is a feasible workaround

Right, that makes sense by the documented rules of the edit context.

If you select the BooleanGroup itself, you start with its parent to find the edit context root, but once the edit context is outside the group, you can’t descend into it (like other special groups) to make changes.