diff --git a/src/navigation.ts b/src/navigation.ts index 6cbf0866..e8e9b430 100644 --- a/src/navigation.ts +++ b/src/navigation.ts @@ -825,7 +825,8 @@ export class Navigation { : workspace.keyboardAccessibilityMode; return ( !!accessibilityMode && - this.getState(workspace) !== Constants.STATE.NOWHERE + this.getState(workspace) !== Constants.STATE.NOWHERE && + !Blockly.getFocusManager().ephemeralFocusTaken() ); } diff --git a/test/webdriverio/test/basic_test.ts b/test/webdriverio/test/basic_test.ts index 2902e28d..db496208 100644 --- a/test/webdriverio/test/basic_test.ts +++ b/test/webdriverio/test/basic_test.ts @@ -349,4 +349,18 @@ suite('Keyboard navigation on Fields', function () { .expect(await getCurrentFocusedBlockId(this.browser)) .equal('draw_emoji_1'); }); + + test('Do not navigate while field editor is open', async function () { + // Open a field editor dropdown + await focusOnBlockField(this.browser, 'logic_boolean_1', 'BOOL'); + await this.browser.pause(PAUSE_TIME); + await this.browser.keys(Key.Enter); + await this.browser.pause(PAUSE_TIME); + + // Try to navigate to a different block + await keyRight(this.browser); + + // The same field should still be focused + chai.assert.equal(await getFocusedFieldName(this.browser), 'BOOL'); + }); }); diff --git a/test/webdriverio/test/clipboard_test.ts b/test/webdriverio/test/clipboard_test.ts index c21a57ce..062f8ad1 100644 --- a/test/webdriverio/test/clipboard_test.ts +++ b/test/webdriverio/test/clipboard_test.ts @@ -15,6 +15,8 @@ import { ElementWithId, tabNavigateToWorkspace, focusOnBlock, + focusOnBlockField, + blockIsPresent, } from './test_setup.js'; import {Key, KeyAction, PointerAction, WheelAction} from 'webdriverio'; @@ -111,6 +113,22 @@ suite('Clipboard test', function () { 'Blocks on the workspace should not have changed', ); }); + + test('Do not cut block while field editor is open', async function () { + // Open a field editor + await focusOnBlockField(this.browser, 'draw_circle_1_color', 'COLOUR'); + await this.browser.pause(PAUSE_TIME); + await this.browser.keys(Key.Enter); + await this.browser.pause(PAUSE_TIME); + + // Try to cut block while field editor is open + await this.browser.keys([Key.Ctrl, 'x']); + + // Block is not deleted + chai.assert.isTrue( + await blockIsPresent(this.browser, 'draw_circle_1_color'), + ); + }); }); /** diff --git a/test/webdriverio/test/delete_test.ts b/test/webdriverio/test/delete_test.ts index aa7a5eea..8564fabd 100644 --- a/test/webdriverio/test/delete_test.ts +++ b/test/webdriverio/test/delete_test.ts @@ -16,6 +16,7 @@ import { PAUSE_TIME, tabNavigateToWorkspace, keyRight, + focusOnBlockField, } from './test_setup.js'; import {Key} from 'webdriverio'; @@ -218,4 +219,18 @@ suite('Deleting Blocks', function () { 'p5_setup_1', ); }); + + test('Do not delete block while field editor is open', async function () { + // Open a field editor + await focusOnBlockField(this.browser, 'colour_picker_1', 'COLOUR'); + await this.browser.pause(PAUSE_TIME); + await this.browser.keys(Key.Enter); + await this.browser.pause(PAUSE_TIME); + + // Try to delete block while field editor is open + await this.browser.keys(Key.Backspace); + + // Block is not deleted + chai.assert.isTrue(await blockIsPresent(this.browser, 'colour_picker_1')); + }); }); diff --git a/test/webdriverio/test/keyboard_mode_test.ts b/test/webdriverio/test/keyboard_mode_test.ts index 98ed5fbe..96f04cb7 100644 --- a/test/webdriverio/test/keyboard_mode_test.ts +++ b/test/webdriverio/test/keyboard_mode_test.ts @@ -80,9 +80,7 @@ suite( // Make sure we're on a copyable block so that copy occurs await focusOnBlock(this.browser, 'controls_if_2'); await this.browser.pause(PAUSE_TIME); - await this.browser.keys(Key.Ctrl); - await this.browser.keys('c'); - await this.browser.keys(Key.Ctrl); // release ctrl key + await this.browser.keys([Key.Ctrl, 'c']); await this.browser.pause(PAUSE_TIME); chai.assert.isFalse(await isKeyboardNavigating(this.browser)); @@ -92,9 +90,7 @@ suite( }); await this.browser.pause(PAUSE_TIME); - await this.browser.keys(Key.Ctrl); - await this.browser.keys('c'); - await this.browser.keys(Key.Ctrl); // release ctrl key + await this.browser.keys([Key.Ctrl, 'c']); await this.browser.pause(PAUSE_TIME); chai.assert.isTrue(await isKeyboardNavigating(this.browser));