From 2767190953f9fde25ffaa4486686dbe4c232fc2f Mon Sep 17 00:00:00 2001 From: Mike Harvey <43474485+mikeharv@users.noreply.github.com> Date: Fri, 26 Jun 2026 15:36:04 -0400 Subject: [PATCH] fix: recompute field ARIA when editor is closed --- packages/blockly/core/field_input.ts | 2 ++ .../blockly/tests/mocha/field_number_test.js | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/packages/blockly/core/field_input.ts b/packages/blockly/core/field_input.ts index 3c9db623cb6..bdf3c189136 100644 --- a/packages/blockly/core/field_input.ts +++ b/packages/blockly/core/field_input.ts @@ -551,6 +551,8 @@ export abstract class FieldInput extends Field< const clickTarget = this.getClickTarget_(); if (!clickTarget) throw new Error('A click target has not been set.'); dom.removeClass(clickTarget, 'blocklyEditing'); + + this.recomputeAriaContext(); } /** diff --git a/packages/blockly/tests/mocha/field_number_test.js b/packages/blockly/tests/mocha/field_number_test.js index 612066b786f..270cac73173 100644 --- a/packages/blockly/tests/mocha/field_number_test.js +++ b/packages/blockly/tests/mocha/field_number_test.js @@ -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', {