diff --git a/packages/blockly/core/gesture.ts b/packages/blockly/core/gesture.ts index 2ee1b60ba23..bf50411e9ad 100644 --- a/packages/blockly/core/gesture.ts +++ b/packages/blockly/core/gesture.ts @@ -975,9 +975,17 @@ export class Gesture { * @internal */ setStartBlock(block: BlockSvg) { - // If the gesture already went through a block child, don't set the start - // block. - if (!this.startBlock && !this.startBubble && !this.startIcon) { + // If the gesture already went through a clickable block child, don't set + // the start block. + if ( + !this.startBlock && + !this.startBubble && + (!this.startIcon || + (block.isInFlyout && + !this.startIcon.isClickableInFlyout?.( + !!block.workspace.getFlyout()?.autoClose, + ))) + ) { this.startBlock = block; if (block.isInFlyout && block !== block.getRootBlock()) { this.setTargetBlock(block.getRootBlock()); diff --git a/packages/blockly/tests/browser/test/basic_playground_test.mjs b/packages/blockly/tests/browser/test/basic_playground_test.mjs index 72b3894a6a3..736068b2551 100644 --- a/packages/blockly/tests/browser/test/basic_playground_test.mjs +++ b/packages/blockly/tests/browser/test/basic_playground_test.mjs @@ -250,6 +250,7 @@ suite('Focused nodes are scrolled into bounds', function () { await this.browser.execute(() => { window.focusScrollTest = async (testcase) => { const workspace = Blockly.getMainWorkspace(); + Blockly.getFocusManager().focusNode(workspace); const metrics = workspace.getMetricsManager(); const initialViewport = metrics.getViewMetrics(true); const elementBounds = await testcase(workspace); diff --git a/packages/blockly/tests/browser/test/test_setup.mjs b/packages/blockly/tests/browser/test/test_setup.mjs index 0a8998c3efe..4a5a14093a1 100644 --- a/packages/blockly/tests/browser/test/test_setup.mjs +++ b/packages/blockly/tests/browser/test/test_setup.mjs @@ -179,11 +179,14 @@ export async function getSelectedBlockElement(browser) { /** * @param browser The active WebdriverIO Browser object. * @param id The ID of the Blockly block to search for. + * @param toolbox True if this block is in the toolbox (which must be open already). * @return A Promise that resolves to the root SVG element of the block with * the given ID, as an interactable browser element. */ -export async function getBlockElementById(browser, id) { - const elem = await browser.$(`[data-id="${id}"]`); +export async function getBlockElementById(browser, id, toolbox) { + const elem = await browser.$( + `${toolbox ? '' : '.blocklySvg'} [data-id="${id}"]`, + ); elem['id'] = id; return elem; } @@ -245,7 +248,7 @@ async function getTargetableBlockElement(browser, blockId, toolbox) { toolbox, ); - return await getBlockElementById(browser, id); + return await getBlockElementById(browser, id, toolbox); } /** @@ -584,9 +587,14 @@ export async function contextMenuSelect(browser, block, itemText) { await clickBlock(browser, block.id, {button: 2}); await browser.pause(PAUSE_TIME); - const item = await browser.$(`div=${itemText}`); - await item.waitForExist(); - await item.click(); + const items = await browser.$$('.blocklyMenuItemContent'); + for (const item of items) { + const text = await item.getText(); + if (text.includes(itemText)) { + await item.click(); + break; + } + } await browser.pause(PAUSE_TIME); } @@ -599,7 +607,9 @@ export async function contextMenuSelect(browser, block, itemText) { * @return A Promise that resolves when the actions are complete. */ export async function openMutatorForBlock(browser, block) { - const icon = await browser.$(`[data-id="${block.id}"] > g.blocklyIconGroup`); + const icon = await browser.$( + `.blocklySvg [data-id="${block.id}"] > g.blocklyIconGroup`, + ); await icon.click(); } diff --git a/packages/blockly/tests/browser/test/workspace_comment_test.mjs b/packages/blockly/tests/browser/test/workspace_comment_test.mjs index db42f30991a..d00ef4d3c2a 100644 --- a/packages/blockly/tests/browser/test/workspace_comment_test.mjs +++ b/packages/blockly/tests/browser/test/workspace_comment_test.mjs @@ -179,7 +179,9 @@ suite('Workspace comments', function () { const textArea = await this.browser.$('.blocklyComment .blocklyTextarea'); await textArea.addValue('test text'); // Deselect text area to fire browser change event. - await this.browser.$('.blocklyWorkspace').click(); + await this.browser.execute(() => { + Blockly.getFocusManager().focusNode(Blockly.getMainWorkspace()); + }); chai.assert.equal( await getCommentText(this.browser, commentId),