Skip to content
Open
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
4 changes: 1 addition & 3 deletions core/gesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,13 +777,11 @@ export class Gesture {
this.setStartWorkspace(ws);
this.mostRecentEvent = e;

if (!this.startBlock && !this.startBubble && !this.startComment) {
if (!this.targetBlock && !this.startBubble && !this.startComment) {
// Ensure the workspace is selected if nothing else should be. Note that
// this is focusNode() instead of focusTree() because if any active node
// is focused in the workspace it should be defocused.
getFocusManager().focusNode(ws);
} else if (this.startBlock) {
getFocusManager().focusNode(this.startBlock);
}

this.doStart(e);
Expand Down
38 changes: 36 additions & 2 deletions tests/mocha/gesture_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
sharedTestSetup,
sharedTestTeardown,
} from './test_helpers/setup_teardown.js';
import {dispatchPointerEvent} from './test_helpers/user_input.js';

Check failure on line 15 in tests/mocha/gesture_test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `dispatchPointerEvent}·from·'./test_helpers/user_input` with `getProperSimpleJson}·from·'./test_helpers/toolbox_definitions`
import {getProperSimpleJson} from './test_helpers/toolbox_definitions.js';

Check failure on line 16 in tests/mocha/gesture_test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `getProperSimpleJson}·from·'./test_helpers/toolbox_definitions` with `dispatchPointerEvent}·from·'./test_helpers/user_input`

suite('Gesture', function () {
function testGestureIsFieldClick(block, isFieldClick, eventsFireStub) {
Expand Down Expand Up @@ -54,8 +55,12 @@
setup(function () {
sharedTestSetup.call(this);
defineBasicBlockWithField();
const toolbox = document.getElementById('gesture-test-toolbox');
this.workspace = Blockly.inject('blocklyDiv', {toolbox: toolbox});
const toolbox = getProperSimpleJson();
toolbox.contents.unshift({
'kind': 'block',

Check failure on line 60 in tests/mocha/gesture_test.js

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
'type': 'test_field_block',

Check failure on line 61 in tests/mocha/gesture_test.js

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
});

Check failure on line 62 in tests/mocha/gesture_test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `↹↹` with `····`
this.workspace = Blockly.inject('blocklyDiv', {toolbox});
});

teardown(function () {
Expand Down Expand Up @@ -94,4 +99,33 @@
const block = getTopFlyoutBlock(flyout);
testGestureIsFieldClick(block, true, this.eventsFireStub);
});

Check failure on line 102 in tests/mocha/gesture_test.js

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
test('Clicking on shadow block does not select it', function () {
const flyout = this.workspace.getFlyout(true);

Check failure on line 104 in tests/mocha/gesture_test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `↹↹` with `····`
flyout.createBlock(flyout.getWorkspace().getBlocksByType('logic_compare')[0]);

Check failure on line 105 in tests/mocha/gesture_test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `↹↹flyout.createBlock(flyout.getWorkspace().getBlocksByType('logic_compare')[0]` with `····flyout.createBlock(⏎······flyout.getWorkspace().getBlocksByType('logic_compare')[0],⏎····`
const block = this.workspace.getBlocksByType('logic_compare')[0];

Check failure on line 106 in tests/mocha/gesture_test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `↹↹` with `····`
const shadowBlock = block.getInput('A').connection.targetBlock();

Check failure on line 107 in tests/mocha/gesture_test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `↹↹` with `····`

this.eventsFireStub.resetHistory();
const eventTarget = shadowBlock.getSvgRoot();
dispatchPointerEvent(eventTarget, 'pointerdown');
dispatchPointerEvent(eventTarget, 'pointerup');
dispatchPointerEvent(eventTarget, 'click');

// The shadow block should not be selected, even though it was clicked.
assertEventNotFired(
this.eventsFireStub,
Blockly.Events.Selected,
{newElementId: shadowBlock.id, type: EventType.SELECTED},
this.workspace.id,
);

// Its parent block should be selected, however.
assertEventFired(
this.eventsFireStub,
Blockly.Events.Selected,
{newElementId: block.id, type: EventType.SELECTED},
this.workspace.id,
);
})
});
Loading