mirror of
https://github.com/google/blockly.git
synced 2026-01-06 08:30:13 +01:00
fix: update disabled status after rendering (#7172)
* fix: update disabled status after rendering * fix: add test for json disabled
This commit is contained in:
committed by
GitHub
parent
817ffab754
commit
cb8ed73c48
@@ -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_();
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user