mirror of
https://github.com/google/blockly.git
synced 2026-06-01 00:40:08 +02:00
fix: dont show input number in connection labels (#9940)
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user