Skip to content

Commit efb5a2e

Browse files
authored
fix: check for a drag specifically rather than a gesture for shortcuts (#9194)
1 parent 7ad18f7 commit efb5a2e

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

core/shortcut_items.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import * as clipboard from './clipboard.js';
1111
import {RenderedWorkspaceComment} from './comments.js';
1212
import * as eventUtils from './events/utils.js';
1313
import {getFocusManager} from './focus_manager.js';
14-
import {Gesture} from './gesture.js';
1514
import {ICopyData, isCopyable as isICopyable} from './interfaces/i_copyable.js';
1615
import {isDeletable as isIDeletable} from './interfaces/i_deletable.js';
1716
import {isDraggable} from './interfaces/i_draggable.js';
@@ -67,7 +66,7 @@ export function registerDelete() {
6766
focused != null &&
6867
isIDeletable(focused) &&
6968
focused.isDeletable() &&
70-
!Gesture.inProgress() &&
69+
!workspace.isDragging() &&
7170
// Don't delete the block if a field editor is open
7271
!getFocusManager().ephemeralFocusTaken()
7372
);
@@ -322,7 +321,7 @@ export function registerUndo() {
322321
preconditionFn(workspace) {
323322
return (
324323
!workspace.isReadOnly() &&
325-
!Gesture.inProgress() &&
324+
!workspace.isDragging() &&
326325
!getFocusManager().ephemeralFocusTaken()
327326
);
328327
},
@@ -360,7 +359,7 @@ export function registerRedo() {
360359
name: names.REDO,
361360
preconditionFn(workspace) {
362361
return (
363-
!Gesture.inProgress() &&
362+
!workspace.isDragging() &&
364363
!workspace.isReadOnly() &&
365364
!getFocusManager().ephemeralFocusTaken()
366365
);

tests/mocha/shortcut_items_test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,13 +434,13 @@ suite('Keyboard Shortcut Items', function () {
434434
});
435435
});
436436
});
437-
// Do not undo if a gesture is in progress.
438-
suite('Gesture in progress', function () {
437+
// Do not undo if a drag is in progress.
438+
suite('Drag in progress', function () {
439439
testCases.forEach(function (testCase) {
440440
const testCaseName = testCase[0];
441441
const keyEvent = testCase[1];
442442
test(testCaseName, function () {
443-
sinon.stub(Blockly.Gesture, 'inProgress').returns(true);
443+
sinon.stub(this.workspace, 'isDragging').returns(true);
444444
this.injectionDiv.dispatchEvent(keyEvent);
445445
sinon.assert.notCalled(this.undoSpy);
446446
sinon.assert.notCalled(this.hideChaffSpy);
@@ -494,13 +494,13 @@ suite('Keyboard Shortcut Items', function () {
494494
});
495495
});
496496
});
497-
// Do not undo if a gesture is in progress.
498-
suite('Gesture in progress', function () {
497+
// Do not redo if a drag is in progress.
498+
suite('Drag in progress', function () {
499499
testCases.forEach(function (testCase) {
500500
const testCaseName = testCase[0];
501501
const keyEvent = testCase[1];
502502
test(testCaseName, function () {
503-
sinon.stub(Blockly.Gesture, 'inProgress').returns(true);
503+
sinon.stub(this.workspace, 'isDragging').returns(true);
504504
this.injectionDiv.dispatchEvent(keyEvent);
505505
sinon.assert.notCalled(this.redoSpy);
506506
sinon.assert.notCalled(this.hideChaffSpy);
@@ -534,8 +534,8 @@ suite('Keyboard Shortcut Items', function () {
534534
sinon.assert.calledWith(this.undoSpy, true);
535535
sinon.assert.calledOnce(this.hideChaffSpy);
536536
});
537-
test('Not called when a gesture is in progress', function () {
538-
sinon.stub(Blockly.Gesture, 'inProgress').returns(true);
537+
test('Not called when a drag is in progress', function () {
538+
sinon.stub(this.workspace, 'isDragging').returns(true);
539539
this.injectionDiv.dispatchEvent(this.ctrlYEvent);
540540
sinon.assert.notCalled(this.undoSpy);
541541
sinon.assert.notCalled(this.hideChaffSpy);

0 commit comments

Comments
 (0)