From ea0479e6e219bdbdbc2f777afe7444db3a949bf4 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Wed, 6 May 2026 11:14:57 -0700 Subject: [PATCH] fix: Adjust keyboard navigation of external inputs (#9820) * fix: Adjust keyboard navigation of external inputs * chore: Adjust docstrings * chore: Improve docs --- packages/blockly/core/block_svg.ts | 5 ++++- packages/blockly/core/inputs/input.ts | 15 ++++++++------- .../core/keyboard_nav/navigators/navigator.ts | 19 ------------------- 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/packages/blockly/core/block_svg.ts b/packages/blockly/core/block_svg.ts index dba65a6b3..78baf0063 100644 --- a/packages/blockly/core/block_svg.ts +++ b/packages/blockly/core/block_svg.ts @@ -1977,7 +1977,10 @@ export class BlockSvg } /** - * Returns an ID for the visual "row" this block is part of. + * Returns an ID for the logical "row" this block is part of. A "row" is + * bounded by a previous/next connection, a statement input, or a block stack + * boundary; all blocks/inputs nested inside of one of those are conceptually + * part of its same row. * * @internal */ diff --git a/packages/blockly/core/inputs/input.ts b/packages/blockly/core/inputs/input.ts index 074ef4f51..f85516d7b 100644 --- a/packages/blockly/core/inputs/input.ts +++ b/packages/blockly/core/inputs/input.ts @@ -361,7 +361,10 @@ export class Input { } /** - * Returns an ID for the visual "row" this input is part of. + * Returns an ID for the logical "row" this input is part of. A "row" is + * bounded by a previous/next connection, a statement input, or a block stack + * boundary; all blocks/inputs nested inside of one of those are conceptually + * part of its same row. * * @internal */ @@ -377,19 +380,17 @@ export class Input { const precedingStatementInput = inputs[inputIndex - 1].connection?.type === ConnectionType.NEXT_STATEMENT; - // Each subsequent (a) external input (b) statement input or (c) inline - // input following a statement input is on its own row and has its own row - // ID. + // Each subsequent statement input or value input following a statement + // input is on its own row and has its own row ID. if ( - !this.getSourceBlock().getInputsInline() || this.connection?.type === ConnectionType.NEXT_STATEMENT || precedingStatementInput ) { return `${this.getSourceBlock().id}-input${inputIndex}`; } - // Value inputs on a inline input block have the same row ID as their - // preceding input, since they're all on one row. + // Value inputs have the same row ID as their preceding input, since + // they're all on one row. return inputs[inputIndex - 1].getRowId(); } diff --git a/packages/blockly/core/keyboard_nav/navigators/navigator.ts b/packages/blockly/core/keyboard_nav/navigators/navigator.ts index 2d50adb3f..e7c203af9 100644 --- a/packages/blockly/core/keyboard_nav/navigators/navigator.ts +++ b/packages/blockly/core/keyboard_nav/navigators/navigator.ts @@ -5,7 +5,6 @@ */ import {BlockSvg} from '../../block_svg.js'; -import {ConnectionType} from '../../connection_type.js'; import {Field} from '../../field.js'; import {getFocusManager} from '../../focus_manager.js'; import {Icon} from '../../icons/icon.js'; @@ -182,24 +181,6 @@ export class Navigator { * "row" as the given node, or null if there is none. */ getOutNode(node = getFocusManager().getFocusedNode()): IFocusableNode | null { - // Special case: blocks and input value connections on blocks with external - // inputs should always navigate to the parent block, even though they're - // not necessarily on the same visual row. - const connection = - node instanceof BlockSvg - ? node.outputConnection?.targetConnection - : node instanceof RenderedConnection && - node.type === ConnectionType.INPUT_VALUE - ? node - : null; - if ( - connection && - !connection.getSourceBlock().getInputsInline() && - connection !== connection.getSourceBlock().inputList[0].connection - ) { - return connection.getSourceBlock(); - } - return this.getPreviousNodeImpl(node, node, NavigationDirection.OUT); }