Skip to main content

blockly > Field > computeAriaLabel

Field.computeAriaLabel() method

Computes a descriptive ARIA label to represent this field with configurable verbosity.

A 'verbose' label includes type information, if available, whereas a non-verbose label only contains the field's value.

Note that this will always return the latest representation of the field's label which may differ from any previously set ARIA label for the field itself. Implementations are largely responsible for ensuring that the field's ARIA label is set correctly at relevant moments in the field's lifecycle (such as when its value changes).

Finally, it is never guaranteed that implementations use the label returned by this method for their actual ARIA label. Some implementations may rely on other contexts to convey information like the field's value. Example: checkboxes represent their checked/non-checked status (i.e. value) through a separate ARIA property.

If the field's value is empty then it will return a localized placeholder indicating that its value is empty. If this method returns an empty string, the output will be ignored when composing the block-level ARIA label. Make sure you want your label hidden from screenreaders before returning an empty string.

Signature:

computeAriaLabel(includeTypeInfo?: boolean): string;

Parameters

Parameter

Type

Description

includeTypeInfo

boolean

(Optional) Whether to include the field's type information in the returned label, if available.

Returns:

string