fix: Enable blocks if user can't manually enable them. #8354
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The basics
The details
Resolves
Fixes #8310
Proposed Changes
When any disabled reason is removed, and the workspace is configured to not allow manually disabling/enabling, and a block is currently disabled for the manual reason, remove the manual reason in addition to whatever reason initiated the change.
Reason for Changes
A legacy serialized workspace does not specify the reason why blocks are disabled. When loaded with blocks that had been disabled due to being orphaned but without a recorded reason, Blockly defaults to using the manually disabled reason. However, some workspaces are configured to disallow disabling/enabling blocks, in which case the user can't remove the manually disabled reason.
For the specific case where a workspace does not allow manually disabling or enabling blocks, and a block currently has the manually disabled reason, and some other disabled reason is being removed (e.g. the block is no longer orphaned), then removing the manually disabled reason will allow the block to be fully enabled again.
Test Coverage
I haven't created any unit tests for this legacy workaround yet, but I did have to explicitly set the option
{disable: true}
in a test workspace to get one test method to pass since it was designed for the common case where users are allowed to manually disable blocks.I manually tested that the workaround behaves as intended by using the browser console to set
Blockly.getMainWorkspace().options.disable = false
after manually disabling a block.Documentation
N/A
Additional Information
N/A