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
1 change: 1 addition & 0 deletions plugins/workspace-minimap/src/focus_region.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const blockEvents = new Set<string>([
Blockly.Events.BLOCK_DELETE,
Blockly.Events.BLOCK_DRAG,
Blockly.Events.BLOCK_MOVE,
Blockly.Events.VAR_RENAME,
]);

const borderRadius = 6;
Expand Down
3 changes: 3 additions & 0 deletions plugins/workspace-minimap/src/minimap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const blockEvents = new Set<string>([
Blockly.Events.BLOCK_DELETE,
Blockly.Events.BLOCK_DRAG,
Blockly.Events.BLOCK_MOVE,
Blockly.Events.VAR_CREATE,
Blockly.Events.VAR_DELETE,
Blockly.Events.VAR_RENAME,
]);

/** Default primary-workspace pixels to pan per arrow keypress. */
Expand Down
39 changes: 39 additions & 0 deletions plugins/workspace-minimap/test/minimap_tests.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,45 @@ suite('Positioning the minimap in the primary workspace', function () {
});
});

suite('Mirroring events', function () {
setup(function () {
this.jsdomCleanup = require('jsdom-global')(
'<!DOCTYPE html><div id="blocklyDiv"></div>',
);
global.SVGElement = window.SVGElement;
window.requestAnimationFrame = (callback) => setTimeout(callback, 0);
window.cancelAnimationFrame = (id) => clearTimeout(id);
this.workspace = Blockly.inject('blocklyDiv', {
move: {scrollbars: true},
});
this.minimap = new Minimap(this.workspace);
this.minimap.init();
});

teardown(function () {
this.minimap.dispose();
this.workspace.dispose();
this.jsdomCleanup();
});

test('Renaming a variable updates the minimap', async function () {
const variable = this.workspace.getVariableMap().createVariable('a');
const block = this.workspace.newBlock('variables_set');
block.getField('VAR').setValue(variable.getId());
await new Promise((resolve) => setTimeout(resolve, 0));

this.workspace.getVariableMap().renameVariable(variable, 'b');
await new Promise((resolve) => setTimeout(resolve, 0));

const minimapBlock = this.minimap.minimapWorkspace.getBlockById(block.id);
assert.equal(
minimapBlock.getField('VAR').getText(),
'b',
'Minimap block should show the renamed variable',
);
});
});

suite('Keyboard navigation', function () {
setup(function () {
this.jsdomCleanup = require('jsdom-global')(
Expand Down
Loading