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
2 changes: 2 additions & 0 deletions packages/blockly/core/field_input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,8 @@ export abstract class FieldInput<T extends InputTypes> extends Field<
const clickTarget = this.getClickTarget_();
if (!clickTarget) throw new Error('A click target has not been set.');
dom.removeClass(clickTarget, 'blocklyEditing');

this.recomputeAriaContext();
}

/**
Expand Down
18 changes: 18 additions & 0 deletions packages/blockly/tests/mocha/field_number_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,24 @@ suite('Number Fields', function () {
const updatedLabel = this.focusableElement.getAttribute('aria-label');
assert.isTrue(updatedLabel.includes('1'));
});
test('ARIA label resets after closing editor with invalid input', function () {
this.field.setValue(5);
this.field.showEditor();

this.field.htmlInput_.value = 'dog';
this.field.onHtmlInputChange(null);
assert.equal(this.field.getValue(), 5);

const labelWhileInvalid =
this.focusableElement.getAttribute('aria-label');
assert.include(labelWhileInvalid, 'dog');

Blockly.WidgetDiv.hideIfOwner(this.field);

const label = this.focusableElement.getAttribute('aria-label');
assert.notInclude(label, 'dog');
assert.include(label, '5');
});
suite('Full block fields', function () {
setup(function () {
this.workspace = Blockly.inject('blocklyDiv', {
Expand Down
Loading