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
6 changes: 0 additions & 6 deletions core/field_dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {Coordinate} from './utils/coordinate.js';
import * as dom from './utils/dom.js';
import * as parsing from './utils/parsing.js';
import * as utilsString from './utils/string.js';
import * as style from './utils/style.js';
import {Svg} from './utils/svg.js';

/**
Expand Down Expand Up @@ -304,11 +303,6 @@ export class FieldDropdown extends Field<string> {

if (this.selectedMenuItem) {
this.menu_!.setHighlighted(this.selectedMenuItem);
style.scrollIntoContainerView(
this.selectedMenuItem.getElement()!,
dropDownDiv.getContentDiv(),
true,
);
}

this.applyColour();
Expand Down
10 changes: 10 additions & 0 deletions core/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ export function inject(
});

browserEvents.conditionalBind(subContainer, 'keydown', null, onKeyDown);
browserEvents.conditionalBind(
dropDownDiv.getContentDiv(),
'keydown',
null,
onKeyDown,
);
const widgetContainer = WidgetDiv.getDiv();
if (widgetContainer) {
browserEvents.conditionalBind(widgetContainer, 'keydown', null, onKeyDown);
}

return workspace;
}
Expand Down
12 changes: 8 additions & 4 deletions core/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,14 @@ export class Menu {
this.highlightedItem = item;
// Bring the highlighted item into view. This has no effect if the menu is
// not scrollable.
const el = this.getElement() as Element;
style.scrollIntoContainerView(item.getElement() as Element, el);

aria.setState(el, aria.State.ACTIVEDESCENDANT, item.getId());
const el = this.getElement();
if (el) {
aria.setState(el, aria.State.ACTIVEDESCENDANT, item.getId());
}
item.getElement()?.scrollIntoView({
block: 'nearest',
inline: 'start',
});
}
}

Expand Down
14 changes: 14 additions & 0 deletions core/utils/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// Former goog.module ID: Blockly.utils.style

import {Coordinate} from './coordinate.js';
import * as deprecation from './deprecation.js';
import {Rect} from './rect.js';
import {Size} from './size.js';

Expand Down Expand Up @@ -58,6 +59,7 @@ function getSizeInternal(element: Element): Size {
* @returns Object with width/height properties.
*/
function getSizeWithDisplay(element: Element): Size {
deprecation.warn(`Blockly.utils.style.getSizeWithDisplay()`, 'v11.2', 'v13');
const offsetWidth = (element as HTMLElement).offsetWidth;
const offsetHeight = (element as HTMLElement).offsetHeight;
return new Size(offsetWidth, offsetHeight);
Expand Down Expand Up @@ -130,6 +132,7 @@ export function getViewportPageOffset(): Coordinate {
* @returns The computed border widths.
*/
export function getBorderBox(element: Element): Rect {
deprecation.warn(`Blockly.utils.style.getBorderBox()`, 'v11.2', 'v13');
const left = parseFloat(getComputedStyle(element, 'borderLeftWidth'));
const right = parseFloat(getComputedStyle(element, 'borderRightWidth'));
const top = parseFloat(getComputedStyle(element, 'borderTopWidth'));
Expand All @@ -156,6 +159,12 @@ export function scrollIntoContainerView(
container: Element,
opt_center?: boolean,
) {
deprecation.warn(
`Blockly.utils.style.scrollIntoContainerView()`,
'v11.2',
'v13',
'the native Element.scrollIntoView()',
);
const offset = getContainerOffsetToScrollInto(element, container, opt_center);
container.scrollLeft = offset.x;
container.scrollTop = offset.y;
Expand All @@ -180,6 +189,11 @@ export function getContainerOffsetToScrollInto(
container: Element,
opt_center?: boolean,
): Coordinate {
deprecation.warn(
`Blockly.utils.style.getContainerOffsetToScrollInto()`,
'v11.2',
'v13',
);
// Absolute position of the element's border's top left corner.
const elementPos = getPageOffset(element);
// Absolute position of the container's border's top left corner.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blockly",
"version": "11.2.0",
"version": "11.2.1",
"description": "Blockly is a library for building visual programming editors.",
"keywords": [
"blockly"
Expand Down
2 changes: 1 addition & 1 deletion scripts/gulpfiles/package_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ module.exports = require('./${bundle}');
* This task copies all the media/* files into the release directory.
*/
function packageMedia() {
return gulp.src('media/*')
return gulp.src('media/*', {encoding: false})
.pipe(gulp.dest(`${RELEASE_DIR}/media`));
};

Expand Down
2 changes: 1 addition & 1 deletion tests/browser/test/basic_playground_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ suite('Disabling', function () {
110,
);
await connect(this.browser, child, 'OUTPUT', parent, 'IF0');

await this.browser.pause(PAUSE_TIME);
await contextMenuSelect(this.browser, parent, 'Disable Block');

chai.assert.isTrue(await getIsDisabled(this.browser, child.id));
Expand Down
12 changes: 8 additions & 4 deletions tests/browser/test/delete_blocks_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,14 @@ suite('Delete blocks', function (done) {
)
.waitForExist({timeout: 2000, reverse: true});

// Load the start blocks
await this.browser.execute((blocks) => {
Blockly.serialization.workspaces.load(blocks, Blockly.getMainWorkspace());
}, startBlocks);
// Load the start blocks. This hangs indefinitely if `startBlocks` is
// passed without being stringified.
this.browser.execute((blocks) => {
Blockly.serialization.workspaces.load(
JSON.parse(blocks),
Blockly.getMainWorkspace(),
);
}, JSON.stringify(startBlocks));
// Wait for there to be a block on the main workspace before continuing
(await getBlockElementById(this.browser, firstBlockId)).waitForExist({
timeout: 2000,
Expand Down
3 changes: 3 additions & 0 deletions tests/browser/test/procedure_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ suite('Testing Connecting Blocks', function (done) {
// Setup Selenium for all of the tests
suiteSetup(async function () {
this.browser = await testSetup(testFileLocations.CODE_DEMO);
// Prevent WebDriver from suppressing alerts
// https://github.com/webdriverio/webdriverio/issues/13610#issuecomment-2357768103
this.browser.on('dialog', (dialog) => {});
});

test('Testing Procedure', async function () {
Expand Down
7 changes: 4 additions & 3 deletions tests/browser/test/test_setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export async function driverSetup() {
const options = {
capabilities: {
'browserName': 'chrome',
'unhandledPromptBehavior': 'ignore',
'goog:chromeOptions': {
args: ['--allow-file-access-from-files'],
},
Expand Down Expand Up @@ -254,9 +255,9 @@ export async function getCategory(browser, categoryName) {
export async function getNthBlockOfCategory(browser, categoryName, n) {
const category = await getCategory(browser, categoryName);
await category.click();
const block = await browser.$(
`.blocklyFlyout .blocklyBlockCanvas > g:nth-child(${3 + n * 2})`,
);
const block = (
await browser.$$(`.blocklyFlyout .blocklyBlockCanvas > .blocklyDraggable`)
)[n];
return block;
}

Expand Down
3 changes: 0 additions & 3 deletions tests/browser/test/workspace_comment_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as chai from 'chai';
import * as sinon from 'sinon';
import {testFileLocations, testSetup} from './test_setup.mjs';

suite('Workspace comments', function () {
Expand All @@ -20,8 +19,6 @@ suite('Workspace comments', function () {
});

teardown(async function () {
sinon.restore();

await this.browser.execute(() => {
Blockly.getMainWorkspace().clear();
});
Expand Down
Loading