mirror of
https://github.com/google/blockly.git
synced 2026-05-01 17:40:11 +02:00
fix: Field text hidden from ARIA (#9734)
This commit is contained in:
@@ -476,15 +476,18 @@ export abstract class Field<T = any>
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a field text element. Not to be overridden by subclasses. Instead
|
||||
* Create a field text element. Not to be overridden by subclasses. Instead,
|
||||
* modify the result of the function inside initView, or create a separate
|
||||
* function to call.
|
||||
* function to call. Aria state is hidden; use the aria label for the field
|
||||
* and/or containing block to expose content to screen readers. Text content
|
||||
* for custom blocks can be set after creation.
|
||||
*/
|
||||
protected createTextElement_() {
|
||||
this.textElement_ = dom.createSvgElement(
|
||||
Svg.TEXT,
|
||||
{
|
||||
'class': 'blocklyText blocklyFieldText',
|
||||
'aria-hidden': 'true',
|
||||
},
|
||||
this.fieldGroup_,
|
||||
);
|
||||
|
||||
@@ -944,5 +944,14 @@ suite('Abstract Fields', function () {
|
||||
assert.equal(field.computeAriaLabel(true), 'custom type: custom value');
|
||||
});
|
||||
});
|
||||
|
||||
suite('Field text elements are hidden', function () {
|
||||
test('Field text element has aria-hidden=true', function () {
|
||||
const field = new TestField();
|
||||
field.constants_ = {FIELD_BORDER_RECT_RADIUS: 5};
|
||||
field.initView();
|
||||
assert(field.getTextElement().ariaHidden === 'true');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user