Skip to content

fix: Added comma between labels for fields when composing ARIA label strings#9812

Merged
lizschwab merged 3 commits into
RaspberryPiFoundation:v13from
lizschwab:rpf-9791
May 5, 2026
Merged

fix: Added comma between labels for fields when composing ARIA label strings#9812
lizschwab merged 3 commits into
RaspberryPiFoundation:v13from
lizschwab:rpf-9791

Conversation

@lizschwab
Copy link
Copy Markdown
Contributor

The basics

The details

Resolves

Fixes #9791

Proposed Changes

Adds a comma between inputs when joining together the array of input labels.

Screenshot:

Screenshot 2026-05-04 at 12 11 09 PM

Reason for Changes

This change will add a comma between labels for fields when composing the ARIA label string. This signals to the screenreader that it should pause, which gives screenreader users valuable information about the composition of the block.

Test Coverage

N/A

@lizschwab lizschwab requested a review from a team as a code owner May 4, 2026 20:11
@lizschwab lizschwab requested a review from mikeharv May 4, 2026 20:11
@github-actions github-actions Bot added the PR: fix Fixes a bug label May 4, 2026
@lizschwab lizschwab changed the title fix: Added comma between inputs when composing ARIA label strings fix: Added comma between labels for fields when composing ARIA label strings May 4, 2026
@github-actions github-actions Bot added PR: fix Fixes a bug and removed PR: fix Fixes a bug labels May 4, 2026
@lizschwab lizschwab linked an issue May 4, 2026 that may be closed by this pull request
1 task
Copy link
Copy Markdown
Contributor

@mikeharv mikeharv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that this is a deliberate change, and the behavior has evidently flipped a couple times already, could we add a test?

// AriaLabelProvider and without setting the provider (the default label)
assert.equal(labelA, labelB);
});
test('Field labels are comma separated', function () {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding a test. Unfortunately, I think it's giving a false positive as it is currently written. In fact, it passes without your core change. This is because each of your test inputs below only have a single field. It would work better to model a single input with multiple fields, since getLabel() composes from all labels within the input.
For example, you could do:

const input = this.block.appendDummyInput().appendField('first').appendField('second');
assert.include(input.getLabel(), 'first, second');

Using label fields like this also makes it clear that multiple labels being comma-separated is intentional. If we decided to make an exception for these later, we'd want to expand this to several tests covering different combinations of field types on the same input.

const label = this.block.getAriaLabel();
const inputLabels = this.block.inputList.map((input) => input.getLabel());

assert.include(label, inputLabels.join(', '));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the same .join(', ') here in the test feels like it's going to give a weaker signal than explicit string comparison, since it's very similar to the way we currently implement this in core. If other parts of the implementation broke, this could continue to pass.

.appendField(new Blockly.FieldTextInput('text'), 'NAME');
this.block
.appendDummyInput('VALUE')
.appendField(new Blockly.FieldNumber('number'), 'VALUE');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first constructor arg in Field classes is generally going to be an optional but valid default value. FieldNumber expects a number (or string that can be cast to a number), so this value 'number' ends up equivalent to passing null.

test('Field labels are comma separated', function () {
this.block
.appendDummyInput('NAME')
.appendField(new Blockly.FieldTextInput('text'), 'NAME');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to omit names for fields and inputs in tests (e.g. 'NAME') if we don't need to reference them again later.

@lizschwab lizschwab merged commit 1662e8b into RaspberryPiFoundation:v13 May 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: fix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v13.0.0-beta.2] Block label commas inconsistent

2 participants