From 292911062eb1f63341f60b17e1838099ed3d7af2 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Wed, 16 Jun 2021 11:40:10 -0700 Subject: [PATCH] Honour option for collapse in context menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently the ‘collapse’ option is always present, even if flagged off in the inject options. --- core/contextmenu_items.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/contextmenu_items.js b/core/contextmenu_items.js index b4adeb2f7..581de6cdf 100644 --- a/core/contextmenu_items.js +++ b/core/contextmenu_items.js @@ -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';