Skip to content

Commit a4dc621

Browse files
authored
fix: recompute field ARIA when editor is closed (#10079)
1 parent 891b87d commit a4dc621

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

packages/blockly/core/field_input.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ export abstract class FieldInput<T extends InputTypes> extends Field<
551551
const clickTarget = this.getClickTarget_();
552552
if (!clickTarget) throw new Error('A click target has not been set.');
553553
dom.removeClass(clickTarget, 'blocklyEditing');
554+
555+
this.recomputeAriaContext();
554556
}
555557

556558
/**

packages/blockly/tests/mocha/field_number_test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,24 @@ suite('Number Fields', function () {
551551
const updatedLabel = this.focusableElement.getAttribute('aria-label');
552552
assert.isTrue(updatedLabel.includes('1'));
553553
});
554+
test('ARIA label resets after closing editor with invalid input', function () {
555+
this.field.setValue(5);
556+
this.field.showEditor();
557+
558+
this.field.htmlInput_.value = 'dog';
559+
this.field.onHtmlInputChange(null);
560+
assert.equal(this.field.getValue(), 5);
561+
562+
const labelWhileInvalid =
563+
this.focusableElement.getAttribute('aria-label');
564+
assert.include(labelWhileInvalid, 'dog');
565+
566+
Blockly.WidgetDiv.hideIfOwner(this.field);
567+
568+
const label = this.focusableElement.getAttribute('aria-label');
569+
assert.notInclude(label, 'dog');
570+
assert.include(label, '5');
571+
});
554572
suite('Full block fields', function () {
555573
setup(function () {
556574
this.workspace = Blockly.inject('blocklyDiv', {

0 commit comments

Comments
 (0)