Skip to content

Commit

Permalink
Honour option for collapse in context menu
Browse files Browse the repository at this point in the history
Currently the ‘collapse’ option is always present, even if flagged off in the inject options.
  • Loading branch information
NeilFraser committed Jun 18, 2021
1 parent c8bea1f commit 2929110
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions core/contextmenu_items.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,12 @@ Blockly.ContextMenuItems.registerCollapseExpandBlock = function() {
/** @type {!Blockly.ContextMenuRegistry.RegistryItem} */
var collapseExpandOption = {
displayText: function(/** @type {!Blockly.ContextMenuRegistry.Scope} */ scope) {
if (scope.block.isCollapsed()) {
return Blockly.Msg['EXPAND_BLOCK'];
}
return Blockly.Msg['COLLAPSE_BLOCK'];
return scope.block.isCollapsed() ?
Blockly.Msg['EXPAND_BLOCK'] : Blockly.Msg['COLLAPSE_BLOCK'];
},
preconditionFn: function(/** @type {!Blockly.ContextMenuRegistry.Scope} */ scope) {
var block = scope.block;
if (!block.isInFlyout && block.isMovable()) {
if (!block.isInFlyout && block.isMovable() && block.workspace.options.collapse) {
return 'enabled';
}
return 'hidden';
Expand Down

0 comments on commit 2929110

Please sign in to comment.