Skip to content

Constrained move after unconstrained move translates the block in MakeCode #446

@microbit-robert

Description

@microbit-robert

This issue only occurs in MakeCode, and not the blockly-keyboard-experimentation test page.

Reproduction:

  • Insert a top-level block without any constrained positions
  • Move the block using unconstrained move (modifier key and arrows)
  • Attempt to the move the block using constrained move (arrows only)
  • The block unexpectedly moves in the same direction you previously moved the block in unconstrained move mode
  • The amount the block moves increases on each subsequent arrow key press

Please see screen capture below:
Image

What is happening:
The newLoc passed to the overridden drag method is being unexpectedly updated during constrained moves after an unconstrained move has occurred. This then calls drag.super and in turn this.block.moveDuringDrag which actually translates the block. It is unclear why there is a difference in behaviour between MakeCode and the test page.

A potential fix:
This can be fixed by removing the call to info.updateTotalDelta() inside the moveConstrained method, however, the consequences of doing this are not fully understood by us and we want to avoid any negative side effects.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions