mirror of
https://github.com/google/blockly.git
synced 2026-01-11 10:57:07 +01:00
Fix moving cursor when block mutates (#3535)
* Fix moving cursor when block mutates
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user