Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Enable blocks if user can't manually enable them. #8354

Merged
merged 2 commits into from
Jul 22, 2024

Conversation

johnnesky
Copy link
Member

@johnnesky johnnesky commented Jul 12, 2024

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

@johnnesky johnnesky requested a review from a team as a code owner July 12, 2024 21:50
@github-actions github-actions bot added PR: fix Fixes a bug and removed PR: fix Fixes a bug labels Jul 12, 2024
@@ -25,7 +25,7 @@ import {defineRowBlock} from '../test_helpers/block_definitions.js';
suite('Procedures', function () {
setup(function () {
sharedTestSetup.call(this, {fireEventsNow: false});
this.workspace = Blockly.inject('blocklyDiv', {});
this.workspace = Blockly.inject('blocklyDiv', {disable: true});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which test did this change target? Since it's in setup for a suite, I think it will impact multiple tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the test to only modify options in the one affected test method.

@johnnesky johnnesky force-pushed the nesky_manually_disabled branch from c221121 to ca23567 Compare July 18, 2024 18:11
@johnnesky johnnesky force-pushed the nesky_manually_disabled branch from 24396b5 to bd90a48 Compare July 19, 2024 22:33
@rachel-fenichel rachel-fenichel merged commit 40c6d9c into google:develop Jul 22, 2024
7 checks passed
Arun-cn pushed a commit to Arun-cn/blockly that referenced this pull request Jul 24, 2024
* fix: Enable blocks if user can't manually enable them.

* Only change the affected test method.
@johnnesky johnnesky deleted the nesky_manually_disabled branch July 26, 2024 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: fix Fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't re-enable "disabled orphaned blocks" after migration to v11
2 participants