mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
fix: Detect if deleting shadow block affects selection highlight (#8533)
* fix: Detect if deleting shadow block affects selection highlight * Use contains instead of descendsFrom for html consistency. * Added tests. * Removing and manually inlining new contains function.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import * as common from '../../build/src/core/common.js';
|
||||
import {ConnectionType} from '../../build/src/core/connection_type.js';
|
||||
import {EventType} from '../../build/src/core/events/type.js';
|
||||
import * as eventUtils from '../../build/src/core/events/utils.js';
|
||||
@@ -444,6 +445,39 @@ suite('Blocks', function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('Disposing selected shadow block', function () {
|
||||
setup(function () {
|
||||
this.workspace = Blockly.inject('blocklyDiv');
|
||||
this.parentBlock = this.workspace.newBlock('row_block');
|
||||
this.parentBlock.initSvg();
|
||||
this.parentBlock.render();
|
||||
this.parentBlock.inputList[0].connection.setShadowState({
|
||||
'type': 'row_block',
|
||||
'id': 'shadow_child',
|
||||
});
|
||||
this.shadowChild =
|
||||
this.parentBlock.inputList[0].connection.targetConnection.getSourceBlock();
|
||||
});
|
||||
|
||||
teardown(function () {
|
||||
workspaceTeardown.call(this, this.workspace);
|
||||
});
|
||||
|
||||
test('Disposing selected shadow unhighlights parent', function () {
|
||||
const parentBlock = this.parentBlock;
|
||||
common.setSelected(this.shadowChild);
|
||||
assert.isTrue(
|
||||
parentBlock.pathObject.svgRoot.classList.contains('blocklySelected'),
|
||||
'Expected parent to be highlighted after selecting shadow child',
|
||||
);
|
||||
this.shadowChild.dispose();
|
||||
assert.isFalse(
|
||||
parentBlock.pathObject.svgRoot.classList.contains('blocklySelected'),
|
||||
'Expected parent to be unhighlighted after deleting shadow child',
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('Remove Input', function () {
|
||||
|
||||
Reference in New Issue
Block a user