diff --git a/core/field_dropdown.ts b/core/field_dropdown.ts index b1e3b5af26..a79deaee5a 100644 --- a/core/field_dropdown.ts +++ b/core/field_dropdown.ts @@ -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'; /** @@ -304,11 +303,6 @@ export class FieldDropdown extends Field { if (this.selectedMenuItem) { this.menu_!.setHighlighted(this.selectedMenuItem); - style.scrollIntoContainerView( - this.selectedMenuItem.getElement()!, - dropDownDiv.getContentDiv(), - true, - ); } this.applyColour(); diff --git a/core/inject.ts b/core/inject.ts index b425d77b74..40016bc23f 100644 --- a/core/inject.ts +++ b/core/inject.ts @@ -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; } diff --git a/core/menu.ts b/core/menu.ts index b0fb555734..d1c86a8020 100644 --- a/core/menu.ts +++ b/core/menu.ts @@ -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', + }); } } diff --git a/core/utils/style.ts b/core/utils/style.ts index 4f8324be5c..5de69001fb 100644 --- a/core/utils/style.ts +++ b/core/utils/style.ts @@ -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'; @@ -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); @@ -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')); @@ -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; @@ -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. diff --git a/package-lock.json b/package-lock.json index 9b070fb54f..c44ddbfef9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "blockly", - "version": "11.2.0", + "version": "11.2.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "blockly", - "version": "11.2.0", + "version": "11.2.1", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index ca6de2f073..332338eacf 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/scripts/gulpfiles/package_tasks.js b/scripts/gulpfiles/package_tasks.js index 48dfd5b843..89264a0e3c 100644 --- a/scripts/gulpfiles/package_tasks.js +++ b/scripts/gulpfiles/package_tasks.js @@ -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`)); }; diff --git a/tests/browser/test/basic_playground_test.mjs b/tests/browser/test/basic_playground_test.mjs index 55ff58e4b0..c0a1f89303 100644 --- a/tests/browser/test/basic_playground_test.mjs +++ b/tests/browser/test/basic_playground_test.mjs @@ -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)); diff --git a/tests/browser/test/delete_blocks_test.mjs b/tests/browser/test/delete_blocks_test.mjs index 27e17054d5..a5df88705c 100644 --- a/tests/browser/test/delete_blocks_test.mjs +++ b/tests/browser/test/delete_blocks_test.mjs @@ -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, diff --git a/tests/browser/test/procedure_test.mjs b/tests/browser/test/procedure_test.mjs index 34368c7324..c01eb49561 100644 --- a/tests/browser/test/procedure_test.mjs +++ b/tests/browser/test/procedure_test.mjs @@ -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 () { diff --git a/tests/browser/test/test_setup.mjs b/tests/browser/test/test_setup.mjs index 523a5d851f..9b48a3638a 100644 --- a/tests/browser/test/test_setup.mjs +++ b/tests/browser/test/test_setup.mjs @@ -38,6 +38,7 @@ export async function driverSetup() { const options = { capabilities: { 'browserName': 'chrome', + 'unhandledPromptBehavior': 'ignore', 'goog:chromeOptions': { args: ['--allow-file-access-from-files'], }, @@ -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; } diff --git a/tests/browser/test/workspace_comment_test.mjs b/tests/browser/test/workspace_comment_test.mjs index 5719948d0e..516523276f 100644 --- a/tests/browser/test/workspace_comment_test.mjs +++ b/tests/browser/test/workspace_comment_test.mjs @@ -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 () { @@ -20,8 +19,6 @@ suite('Workspace comments', function () { }); teardown(async function () { - sinon.restore(); - await this.browser.execute(() => { Blockly.getMainWorkspace().clear(); });