8000 fix: update disabled status after rendering by maribethb · Pull Request #7172 · google/blockly · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: update disabled status after rendering #7172

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

Merged
merged 2 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/block_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1578,6 +1578,11 @@ export class BlockSvg
this.rendered = true;
dom.startTextWidthCache();

if (!this.isEnabled()) {
// Apply disabled styles if needed.
this.updateDisabled();
}

if (this.isCollapsed()) {
this.updateCollapsed_();
}
Expand Down
16 changes: 16 additions & 0 deletions tests/mocha/block_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2144,6 +2144,22 @@ suite('Blocks', function () {
// Child blocks should stay disabled if they have been set.
chai.assert.isTrue(blockB.disabled);
});
test('Disabled blocks from JSON should have proper disabled status', function () {
const blockJson = {
'type': 'controls_if',
'enabled': false,
};
Blockly.serialization.blocks.append(blockJson, this.workspace);
const block = this.workspace.getTopBlocks(false)[0];
chai.assert.isTrue(
block.visuallyDisabled,
'block should have visuallyDisabled set because it is disabled'
);
chai.assert.isFalse(
block.isEnabled(),
'block should be marked disabled because enabled json property was set to false'
);
});
});
});

Expand Down
0