Skip to content

Commit cf850d5

Browse files
authored
Merge pull request google#6941 from google/rc/v9.3.1
release: v9.3.1
2 parents 9c9aef1 + 15b83d4 commit cf850d5

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

core/connection_checker.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,9 @@ export class ConnectionChecker implements IConnectionChecker {
250250
}
251251

252252
// Don't offer to splice into a stack where the connected block is
253-
// immovable.
254-
if (b.targetBlock() && !b.targetBlock()!.isMovable()) {
253+
// immovable, unless the block is a shadow block.
254+
if (b.targetBlock() && !b.targetBlock()!.isMovable() &&
255+
!b.targetBlock()!.isShadow()) {
255256
return false;
256257
}
257258
break;

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "blockly",
3-
"version": "9.3.0",
3+
"version": "9.3.1",
44
"description": "Blockly is a library for building visual programming editors.",
55
"keywords": [
66
"blockly"

tests/mocha/connection_checker_test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,31 @@ suite('Connection checker', function() {
367367
'Should connect two compatible stack blocks');
368368
});
369369

370+
test('Connect to unmovable shadow block', function() {
371+
// Remove original test blocks.
372+
this.workspace.clear();
373+
374+
// Add the same test blocks, but this time block B is a shadow block.
375+
Blockly.Xml.domToWorkspace(Blockly.utils.xml.textToDom(`<xml xmlns="https://developers.google.com/blockly/xml">
376+
<block type="text_print" id="A" x="-76" y="-112">
377+
<next>
378+
<shadow type="text_print" id="B" movable="false">
379+
</shadow>
380+
</next>
381+
</block>
382+
<block type="text_print" id="C" x="47" y="-118"/>
383+
</xml>`), this.workspace);
384+
[this.blockA, this.blockB, this.blockC] = this.workspace.getAllBlocks(true);
385+
386+
// Try to connect blockC into the input connection of blockA, replacing blockB.
387+
// This is allowed because shadow blocks can always be replaced, even though
388+
// they are unmovable.
389+
chai.assert.isTrue(
390+
this.checker.doDragChecks(
391+
this.blockC.previousConnection, this.blockA.nextConnection, 9000),
392+
'Should connect in place of a shadow block');
393+
});
394+
370395
test('Do not splice into unmovable stack', function() {
371396
// Try to connect blockC above blockB. It shouldn't work because B is not movable
372397
// and is already connected to A's nextConnection.

0 commit comments

Comments
 (0)