fix: dont show input number in connection labels (#9940)

This commit is contained in:
Maribeth Moffatt
2026-05-26 18:57:04 -04:00
committed by GitHub
parent 46ac410723
commit 9273d642db
3 changed files with 31 additions and 6 deletions
+13 -6
View File
@@ -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);
}
/**
@@ -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(
+15
View File
@@ -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');