Skip to content

Commit cf2b68d

Browse files
committed
fix: Strip the 'disabledReasons' property when saving blocks to the backpack.
Disabled blocks that are saved to the backpack retain their 'disabledReasons' property, which makes them impossible to take. Add 'disabledReasons' to the list of stripped keys and apply the stripping to blocks added via the 'Backpackable' interface ('addBackpackables').
1 parent 4058e0b commit cf2b68d

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

plugins/workspace-backpack/src/backpack.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,14 @@ export class Backpack
487487
*/
488488
private cleanFlyoutInfo(dirtyInfo: Blockly.utils.toolbox.FlyoutItemInfo) {
489489
// The keys to remove.
490-
const removeKeys = ['id', 'height', 'width', 'pinned', 'enabled'];
490+
const removeKeys = [
491+
'id',
492+
'height',
493+
'width',
494+
'pinned',
495+
'enabled',
496+
'disabledReasons',
497+
];
491498

492499
// Traverse the object recursively.
493500
const traverseClean = function (
@@ -615,7 +622,10 @@ export class Backpack
615622
backpackables
616623
.map((b) => b.toFlyoutInfo())
617624
.reduce((acc, curr) => [...acc, ...curr])
618-
.map((info) => JSON.stringify(info)),
625+
.map((info) => {
626+
this.cleanFlyoutInfo(info);
627+
return JSON.stringify(info);
628+
}),
619629
);
620630
}
621631

0 commit comments

Comments
 (0)