Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions packages/blockly/core/block_aria_composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/blockly/core/rendered_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
15 changes: 15 additions & 0 deletions packages/blockly/tests/mocha/aria_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Loading