Fix moving cursor when block mutates (#3535)

* Fix moving cursor when block mutates
This commit is contained in:
alschmiedt
2020-01-02 15:12:06 -08:00
committed by GitHub
parent 06c714d13b
commit 4ce67bb108
5 changed files with 13 additions and 20 deletions

View File

@@ -323,11 +323,6 @@ Blockly.Block.prototype.dispose = function(healStack) {
this.workspace.removeChangeListener(this.onchangeWrapper_);
}
if (this.workspace.keyboardAccessibilityMode) {
// No-op if this is called from the block_svg class.
Blockly.navigation.moveCursorOnBlockDelete(this);
}
this.unplug(healStack);
if (Blockly.Events.isEnabled()) {
Blockly.Events.fire(new Blockly.Events.BlockDelete(this));

View File

@@ -376,6 +376,10 @@ Blockly.Mutator.prototype.workspaceChanged_ = function(e) {
block.compose(this.rootBlock_);
block.initSvg();
block.render();
if (Blockly.getMainWorkspace().keyboardAccessibilityMode) {
Blockly.navigation.moveCursorOnBlockMutation(block);
}
var newMutationDom = block.mutationToDom();
var newMutation = newMutationDom && Blockly.Xml.domToText(newMutationDom);
if (oldMutation != newMutation) {
@@ -390,10 +394,6 @@ Blockly.Mutator.prototype.workspaceChanged_ = function(e) {
}, Blockly.BUMP_DELAY);
}
if (oldMutation != newMutation &&
this.workspace_.keyboardAccessibilityMode) {
Blockly.navigation.moveCursorOnBlockMutation(block);
}
// Don't update the bubble until the drag has ended, to avoid moving blocks
// under the cursor.
if (!this.workspace_.isDragging()) {

View File

@@ -23,8 +23,6 @@
goog.provide('Blockly.Workspace');
goog.require('Blockly.Cursor');
goog.require('Blockly.Marker');
goog.require('Blockly.Events');
goog.require('Blockly.utils');
goog.require('Blockly.utils.math');
@@ -111,13 +109,6 @@ Blockly.Workspace = function(opt_options) {
* @private
*/
this.potentialVariableMap_ = null;
/**
* True if keyboard accessibility mode is on, false otherwise.
* @type {boolean}
* @package
*/
this.keyboardAccessibilityMode = false;
};
/**

View File

@@ -155,6 +155,13 @@ Blockly.WorkspaceSvg = function(options,
this.themeManager_.subscribeWorkspace(this);
this.renderer_.getConstants().refreshTheme(this.getTheme());
/**
* True if keyboard accessibility mode is on, false otherwise.
* @type {boolean}
* @package
*/
this.keyboardAccessibilityMode = false;
};
Blockly.utils.object.inherits(Blockly.WorkspaceSvg, Blockly.Workspace);

View File

@@ -90,8 +90,8 @@ suite('Gesture', function() {
};
var ws = Blockly.inject('blocklyDiv', {});
var gesture = new Blockly.Gesture(this.e, ws);
assertFalse(Blockly.getMainWorkspace().keyboardAccessibilityMode);
assertFalse(ws.keyboardAccessibilityMode);
gesture.doWorkspaceClick_(event);
assertTrue(Blockly.getMainWorkspace().keyboardAccessibilityMode);
assertTrue(ws.keyboardAccessibilityMode);
});
});