From 9273d642dbaaf9cf649b70daf55d0fbc001d7da6 Mon Sep 17 00:00:00 2001 From: Maribeth Moffatt Date: Tue, 26 May 2026 18:57:04 -0400 Subject: [PATCH] fix: dont show input number in connection labels (#9940) --- packages/blockly/core/block_aria_composer.ts | 19 +++++++++++++------ packages/blockly/core/rendered_connection.ts | 3 +++ packages/blockly/tests/mocha/aria_test.js | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/packages/blockly/core/block_aria_composer.ts b/packages/blockly/core/block_aria_composer.ts index 6c4bc80b2..4bebba997 100644 --- a/packages/blockly/core/block_aria_composer.ts +++ b/packages/blockly/core/block_aria_composer.ts @@ -328,7 +328,11 @@ export function getInputLabels( * @param input The input that defines the end of the subset. * @returns A list of field/input labels for the given block. */ -export function getInputLabelsSubset(block: BlockSvg, input: Input): string[] { +export function getInputLabelsSubset( + block: BlockSvg, + input: Input, + includeFallbackLabels = true, +): string[] { const inputIndex = block.inputList.indexOf(input); if (inputIndex === -1) { throw new Error( @@ -347,11 +351,14 @@ export function getInputLabelsSubset(block: BlockSvg, input: Input): string[] { .map( (input) => input.getLabel(Verbosity.TERSE, false) || - Msg['INPUT_LABEL_INDEX'].replace( - '%1', - (input.getIndex() + 1).toString(), - ), - ); + (includeFallbackLabels + ? Msg['INPUT_LABEL_INDEX'].replace( + '%1', + (input.getIndex() + 1).toString(), + ) + : undefined), + ) + .filter((label) => label !== undefined); } /** diff --git a/packages/blockly/core/rendered_connection.ts b/packages/blockly/core/rendered_connection.ts index faa448d3a..735d403b0 100644 --- a/packages/blockly/core/rendered_connection.ts +++ b/packages/blockly/core/rendered_connection.ts @@ -355,11 +355,14 @@ export class RenderedConnection // Use the custom label for an input if it exists, otherwise use the // "field row" approach to get the default label for the input. + // Don't include the "input 1" fallback for default labels, since + // the input is already being described as a statement or value input. const parentInputLabel = parentInput?.getAriaLabelText() ?? getInputLabelsSubset( parentInput.getSourceBlock() as BlockSvg, parentInput, + false, ).join(', '); if (this.type === ConnectionType.NEXT_STATEMENT) { aria.setState( diff --git a/packages/blockly/tests/mocha/aria_test.js b/packages/blockly/tests/mocha/aria_test.js index 16d67ac41..ab03593f2 100644 --- a/packages/blockly/tests/mocha/aria_test.js +++ b/packages/blockly/tests/mocha/aria_test.js @@ -626,6 +626,21 @@ suite('ARIA', function () { ); }); + test('statement input connection label does not include the placeholder "input"', function () { + const block = this.renderBlock('controls_repeat_ext'); + const doInput = block.getInput('DO'); + doInput.connection.highlight(); + try { + const label = Blockly.utils.aria.getState( + doInput.connection.getFocusableElement(), + Blockly.utils.aria.State.LABEL, + ); + assert.notInclude(label, 'input'); + } finally { + doInput.connection.unhighlight(); + } + }); + test('last next connection in a populated statement stack uses statement role description and end label', function () { const repeat = this.renderBlock('controls_repeat_ext'); const printBlock = this.renderBlock('text_print');