Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/blockly/core/workspace_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2467,17 +2467,17 @@ export class WorkspaceSvg
* valid gesture exists.
* @internal
*/
getGesture(e: PointerEvent): Gesture | null {
getGesture(e?: PointerEvent): Gesture | null {
// TODO(#8960): Query Mover.isMoving to see if move is in progress
// rather than relying on .keyboardMoveInProgress status flag.
if (this.keyboardMoveInProgress) {
// Normally these would be called from Gesture.doStart.
e.preventDefault();
e.stopPropagation();
e?.preventDefault();
e?.stopPropagation();
return null;
}

const isStart = e.type === 'pointerdown';
const isStart = e?.type === 'pointerdown';
if (isStart && this.currentGesture_?.hasStarted()) {
console.warn('Tried to start the same gesture twice.');
// That's funny. We must have missed a mouse up.
Expand Down
12 changes: 12 additions & 0 deletions packages/blockly/tests/mocha/workspace_svg_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
sharedTestSetup,
sharedTestTeardown,
} from './test_helpers/setup_teardown.js';
import {dispatchPointerEvent} from './test_helpers/user_input.js';
import {testAWorkspace} from './test_helpers/workspace.js';

suite('WorkspaceSvg', function () {
Expand Down Expand Up @@ -114,6 +115,17 @@ suite('WorkspaceSvg', function () {
assert.equal(true, shadowBlock.isDeadOrDying());
});

test('getGesture returns null when no gesture is in progress', function () {
const gesture = this.workspace.getGesture();
assert.isNull(gesture);
});

test('getGesture returns the current gesture when one is in progress', function () {
dispatchPointerEvent(this.workspace.getSvgGroup(), 'pointerdown');
const gesture = this.workspace.getGesture();
assert.isNotNull(gesture);
});

suite('updateToolbox', function () {
test('Passes in null when toolbox exists', function () {
assert.throws(
Expand Down