You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/defining-blocks.md
+15-4Lines changed: 15 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,7 +106,7 @@ parameter = string
106
106
* each `field` is mapped to a field name on the block.
107
107
* the function parameters are mapped to the `$parameter` argument with an identical name. The loader automatically builds a mapping between the block field names and the function names.
108
108
* the block will automatically switch to external inputs (wrapping) when there are four or more parameters.
109
-
* the `|` indicates where to start a new line if the block is in external inputs mode.
109
+
* the `|` indicates where to start a new line if the block is in external inputs mode.
110
110
111
111
## Custom block localization
112
112
@@ -124,11 +124,12 @@ For example,
124
124
export function square(x: number): number {}
125
125
```
126
126
127
-
You can also override the ``jsdoc`` description and parameter info.
127
+
You can also override the ``jsdoc`` description, parameter info, and ariaLabel (for dropdown values).
@@ -339,14 +348,16 @@ Enum is supported and will automatically be represented by a dropdown in blocks.
339
348
enum Button {
340
349
A = 1,
341
350
B = 2,
342
-
//% blockId="ApB" block="A+B"
351
+
//% block="A+B" ariaLabel="A and B"
343
352
AB = 3,
344
353
}
345
354
```
346
355
347
356
* the initializer can be used to map the value
348
-
* the `blockId` attribute can be used to override the block id
349
357
* the `block` attribute can be used to override the rendered string
358
+
* the `ariaLabel` attribute can be used to override the aria label on the dropdown value if the `block` value is not read correctly by screen readers
359
+
360
+
The `block` and `ariaLabel` values can both be localized, either by including a strings JSON file or locally in the comments (see custom block localization section above).
0 commit comments