Commit Graph

107 Commits

Author SHA1 Message Date
Ben Henning
3cf834a6a6 feat: Fix ARIA roles and setup for fields (experimental) (#9384)
## The basics

- [x] I [validated my changes](https://developers.google.com/blockly/guides/contribute/core#making_and_verifying_a_change)

## The details
### Resolves

Fixes #8206
Fixes #8210
Fixes #8213
Fixes #8255
Fixes #8211
Fixes #8212
Fixes #8254
Fixes part of #9301
Fixes part of #9304

### Proposed Changes

This PR completes the remaining ARIA roles and properties needed for all core fields. Specifically:
- #8206: A better name needed to be used for the checkbox value, plus there was an ARIA property missing for actually representing the checkbox state. The latter needed to be updated upon toggling the checkbox, as well. These changes bring checkbox fields in compliance with the ARIA checkbox pattern documented here: https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/.
- #8210: This one required a lot of changes in order to adapt to the ARIA combobox pattern documented here: https://www.w3.org/WAI/ARIA/apg/patterns/combobox/. Specifically:
  - Menus needed to have a unique ID that's also exposed in order to link the combobox element to its menu when open.
  - ARIA's `activedescendant` proved very useful in ensuring that the current dropdown selection is correctly read when the combobox has focus but its menu isn't opened.
  - The default properties available for options (label and value) aren't very good for readout, so a custom ARIA property was added for much clearer option readouts. This is only demonstrated for the math arithmetic block for now.
  - The text element is normally hidden for ARIA but it's useful in conjunction with `activedescendant` to represent the current value selection.
  - Images have been handled here as well (partly as part of #8255) by leveraging their alt text for readouts. This actually seems to work quite well both for current value and selection.
- #8213: Much of the improvements here come from the combobox (`FieldDropdown`) improvements explained above. However one additional bit was done to provide an explicit 'Variable <name>' readout for the purpose of clarity. This demonstrates some contextualization of the value of the field which may be a generally useful pattern to copy in other field contexts.
- #8255: Image fields have been refined since they were redundantly specifying 'image' when an `image` ARIA role is already being used. Now only the alt text is supplied along with the role context. Note that images need special handling since they can sometimes be navigable (such as when they have click handlers).
- #8211: Text input fields have had their labeling improved like all other fields, and the field's value is now exposed via its `text` element since this will show up as a `StaticText` node in the accessibility tree and automatically be read as part of the field's value.
- #8212: This gets the same benefits as the previous point since those improvements were included for both text and number input. However, existing `valuemin` and `valuemax` ARIA properties have been removed. It seems these are really only useful when introducing a slider mechanism (see https://www.w3.org/WAI/ARIA/apg/patterns/slider/) and from testing seems to not really be utilized for the basic text input that `FieldNumber` currently uses. It may be the case that this is a better pattern to use in the future, but it's more likely that other custom fields could benefit from more specific patterns like slider rather than `FieldNumber` being changed in that way.
- #8254 and part of #9304: Field labels have been completely removed from the accessibility node tree since they can never be navigated to (as #8254 explains all labels will be included as part of the block's ARIA label itself for readout parity with navigation options).

Note that it doesn't cover external fields (such as those supplied in blockly-samples), nor does it fully set up the infrastructure work for those. Ultimately that work needs to happen as part of #9301.

Beyond the role work above, this PR also introduces some fundamental work for #9301. Specifically:
- It demonstrates how block definitions could be used to introduce accessibility label customizations (in this case for the options of the arithmetic operator block's drop-down field, plus the block itself).
- It sets up some central label computation for all fields, though more thought is needed on whether this is sufficient for custom fields outside of core Blockly and on how to properly contextualize labels for field values. Core Blockly's fields are fairly simple for representing values which is why that aspect of #9301 didn't need to be solved in this PR. Note that the field labeling here is being used to improve all of the fields above, but also it tries to aggressively fall back to the _next best_ label to be used (though it's possible to run out of options which is why fields still need contextually-specific fallbacks).

### Reason for Changes

Generally the initial approach for implementing labels is leveraging as specific ARIA roles as exist to directly represent the element. This PR is completing that work for all of core Blockly's built-in fields, and laying some of the groundwork for generalizing this support for custom fields.

Having specific roles does potentially introduce inconsistencies across screen readers (though should improve consistency across sites for a single screen reader), and expectations for behaviors (like shortcuts) that may need to be ignored or only partially supported (#9313 is discussing this).

### Test Coverage

Only manual testing has been completed since this is experimental work.

Video demonstrating most of the changes:

[Screen recording 2025-10-01 4.05.35 PM.webm](https://github.com/user-attachments/assets/c7961caa-eae0-4585-8fd9-87d7cbe65988)

### Documentation

N/A -- Experimental work.

### Additional Information

This has only been tested on ChromeVox.
2025-10-01 16:19:06 -07:00
Aaron Dodson
1dd77015e3 fix: Add a label to the toolbox. (#9378) 2025-09-22 13:27:55 -07:00
Maribeth Moffatt
27fe764428 fix: improve screenreader output for workspace comments (#9351)
* fix: improve screenreader output for workspace comments

* fix: run npm run messages to fully add new message

* fix: remove useless bubble label

* fix: use roledescription instead of description
2025-09-18 14:27:41 -07:00
Maribeth Moffatt
2c46686d7d fix: minor fixes to translation files (#9350) 2025-09-09 09:19:17 -07:00
Aaron Dodson
28d6ff7da5 chore: Update messages for keyboard-experiment. (#9152)
* chore: Remove unused messages.

* fix: Remove unneeded message placeholders.

* feat: Add additional messages used in the keyboard experiment.

* chore: Update messages.
2025-06-23 09:14:39 -07:00
Aaron Dodson
c6e58c4f92 feat: Add support for displaying toast-style notifications. (#8896)
* feat: Allow resetting alert/prompt/confirm to defaults.

* chore: Add unit tests for Blockly.dialog.

* fix: Removed TEST_ONLY hack from Blockly.dialog.

* feat: Add a default toast notification implementation.

* feat: Add support for toasts to Blockly.dialog.

* chore: Add tests for default toast implementation.

* chore: Fix docstring.

* refactor: Use default arguments for dialog functions.

* refactor: Add 'close' to the list of messages.

* chore: Add new message in several other places.

* chore: clarify docstrings.

* feat: Make toast assertiveness configurable.
2025-04-21 15:32:45 -07:00
Aaron Dodson
9d127698d6 fix: Add some missing message strings. (#8908)
* fix: Add some missing message strings.

* fix: Prefix messages with SHORTCUTS
2025-04-21 10:44:57 -07:00
Aaron Dodson
cece3f6296 chore: Add messages from the keyboard experiment. (#8904)
* chore: Add messages from the keyboard experiment.

* fix: Resolve duplicate message ID.

* fix: Use placeholders for keyboard shortcuts.
2025-04-21 08:54:39 -07:00
Maribeth Moffatt
0255c580f7 Merge branch 'develop' into merge-v11 2024-05-13 11:20:39 -07:00
Neil Fraser
5a5184ab4f fix: Correct list's "find" and "get" blocks help. (#8041)
* Correct list's "find" and "get" blocks help.

Both blocks were using the same help URL.

Two unrelated results of recompiling messages:
* Allow unwanted 'qqq' messages to be reverted.
* 'constants.json' is unchanged, but sorted.

Also improve python json dumping.
2024-04-26 20:23:43 +02:00
John Nesky
cee7f916bb feat!: Invalid Blocks (#7958)
* feat: Invalid Blocks

* Rename the new json property from invalid to invalidReasons.

* Merged isValid into isEnabled.

* Minor fixes.

* More minor fixes.

* Reverting some stuff that didn't need to change.

* Addressing PR feedback.

* Update the BlockInfo interface to match State.

* Make BlockChange.disabledReason private.
2024-04-17 19:47:51 -07:00
Neil Fraser
f7e6f5cfb1 chore: Recompile messages (#7705)
Sort constants and synonyms so that future changes can be seen in diff.
2023-12-08 18:55:18 +01:00
Neil Fraser
74a72e478f fix: Remove double spaces in translation instructions. (#7704) 2023-12-08 17:14:31 +01:00
laurensvalk
3b234c7f87 fix: Call onFinishEditing_ for fields on mobile. (#7483)
On the desktop, widgetDispose_ will call onFinishEditing_ on close.

This was missing in the mobile counterpart, so any cleanups in onFinishEditing_ would not be called.

Also update the message string comment while we are touching this code.
2023-09-20 06:15:17 -07:00
Christopher Allen
6670db1f2d chore(messages): Update messages (#7220)
* chore(messages): npm run messages

  This is the raw changes made by `npm run messages`, without any
  manual reverts / backporting.

* fix(messages): Backport TranslateWiki hints (with edits)

  Backport changes made to qqq.json by TranslateWiki editors to
  messages.json, with some modifications.

  See https://translatewiki.net/wiki/Template:Optional for details
  of how the {{Optional}} template works.

* chore(messages): Apply backported messages.js changes to qqq.json

  Also manually revert deletion of translation credits.
2023-06-28 15:13:28 -04:00
Beka Westberg
c0934216f8 fix: creating duplicate params via renaming vars (#6885)
* feat: add IVariableHolder

* chore: reorganize variable prompts to early return

* fix: add retriggering prompt for conflicting params

* chore: add unit tests

* chore: fix build

* chore: reorganize checking for param conflicts

* fix: visibility

* chore: rename variable holder interface

* chore: fix typo

* chore: fix lint
2023-03-09 06:00:48 -08:00
Neil Fraser
90b3f75d82 Remove @author tags (#5601)
Our files are up to a decade old, and have churned so much, that the initial author of the file no longer has much meaning.

Furthermore, this will encourage developers to post to the developer group, rather than emailing Googlers (usually me) directly.
2021-10-15 09:50:46 -07:00
Neil Fraser
c9329ea8eb chore: Rollup of all Q3 message changes (#5564)
Courtesy of Translatewiki
2021-09-28 12:20:42 -07:00
Neil Fraser
d627023c0c Recompile of JSON to JS messages.
New dialog OK/Cancel messages.
2021-08-05 10:39:22 -07:00
Christopher Allen
a03cd29b68 Separate script to rebuild msg/json/en.json, qqq.json etc.
There are some files in msg/json/ (currently en.json, qqq.json,
constants.json and synonyms.json) that are generated by
scripts/i18n/js_to_json.py as part of the language file build process
- but this only needs to be done when messages.js is updated and
and usually requires some manual cleanup, so remove this step from the
existing buildLangfiles gulp script and create a separate command
('npm run generate:langfiles') to do this when required.
2021-06-22 10:59:24 +01:00
Sam El-Husseini
55e6f8000e Move i18n scripts under scripts/ (#4044)
* Move i18n scripts under scripts/
2020-07-14 12:07:56 -07:00
Neil Fraser
4e2f8e6e02 Use SPDX licences.
This is a followup to #3127.
At the time, SPDX licenses were pending approval by Google.
2020-02-11 13:27:20 -08:00
alschmiedt
cbf867f441 Add keyboard navigation support for multiple workspaces (#3352)
* Add keyboard navigation support for multiple workspaces
2019-10-28 12:53:51 -07:00
Neil Fraser
b46a4fe286 Bring our license format up to date (#3127)
* Google changed from an Inc to an LLC.

This happened back in 2017 but we didn’t notice.  Officially we should update files from Inc to LLC when they are changed as part of regular edits, but this is a nightmare to remember for the next decade.

* Remove project description/titles from licenses

This is no longer part of Google’s header requirements.  Our existing descriptions were useless (“Visual Blocks Editor”) or grossly obselete (“Visual Blocks Language”).

* License no longer requires URL.

* Fix license regexps.
2019-10-02 14:46:56 -07:00
Sam El-Husseini
8ab51c8639 Remove closure base file dependency (#2976)
* Trim down closure's base dependency even further by removing the dependency on closure's base file.
2019-09-11 17:30:51 -07:00
Sam El-Husseini
b7b4af4edf Add jsdoc to messages (#2774)
* Add jsdoc annotations to messages so that the typescript generator tool picks it up.
2019-08-07 10:34:12 -07:00
Neil Fraser
abc452109e Fix XML across Blockly. (#2727)
Also fixes references to createSvgElement
2019-07-30 15:08:47 -07:00
Beka Westberg
87fbe0447b Fixed procedures not handling empty names. Renenabled/fixed tests. 2019-07-08 09:23:16 -07:00
Neil Fraser
0a2d32c583 Update help URLs to be https. 2019-04-01 11:15:46 -07:00
Neil Fraser
c566c2e712 Fix comment on new message.
/// is needed to indicate translator message.
2019-03-27 15:47:29 -07:00
Beka Westberg
44df2d4680 Changed parent blocks to display "Collapsed blocks contain warnings." instead of having warnings "bubble up" from children. Added message to msg/messages.js . 2018-12-17 14:54:56 -08:00
Nadya Febiana Djojosantoso
c89909bd29 Add math_atan2 strings 2018-10-11 13:29:42 -07:00
Rachel Fenichel
2a37fc849a Add comment messages 2018-04-20 16:47:28 -07:00
Rachel Fenichel
96e2d7d102 Fix #1559 2018-01-24 17:05:58 -08:00
Neil Fraser
7413db1089 Code style 2018-01-05 15:56:20 -08:00
Neil Fraser
eb61152ac2 Add {{Optional}} to help URLs. (#1413)
* Add {{Optional}} to help URLs.
Fixes issue #898.

* Leakage from Blockly Games?

* Propagate msg-Blockly -> msg-blockly change back to messages.js
As made by wikitranslate in 69b10dba79
2018-01-05 15:20:42 -08:00
Tianwei Du
492462e1d4 Develop (#1481)
* variables_dynamic

* make test , and i18n

* Issue #1470

* Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_MUTATION
to make sure setCheck before event trigger

* Update built files from develop.

* fix copyright ,quotes , comments ,  and optimize some flow.

* quotes,change UI , change category custom name

* single setter , remove mutator , colour typo , typed variables create button message

* undo the indent edits.
2017-12-08 08:53:24 -08:00
Neil Fraser
63637a927a Remove unnecessary restriction on variable names. 2017-11-01 12:08:53 -07:00
marisaleung
733d869f8e Add VariableType checks. 2017-07-20 16:47:37 -07:00
Rachel Fenichel
9053dbf9b4 Merge master to develop (#1189)
* Merge master into develop (#1063)

- pick up translation changes
- clean up trailing spaces

* Rebuild for translations

* Localisation updates from https://translatewiki.net.

* Localisation updates from https://translatewiki.net.

* Cherrypick a fix for #1069 and rebuild (#1075)

* Fix #1069 (#1073)

* rebuild

* Localisation updates from https://translatewiki.net.

* Localisation updates from https://translatewiki.net.

* Localisation updates from https://translatewiki.net.

* Localisation updates from https://translatewiki.net.

* Localisation updates from https://translatewiki.net.

* Localisation updates from https://translatewiki.net.

* Localisation updates from https://translatewiki.net.

* Localisation updates from https://translatewiki.net.

* Localisation updates from https://translatewiki.net.

* Localisation updates from https://translatewiki.net.

* Localisation updates from https://translatewiki.net.

* Rebuild compressed files

* Add some translatewiki annotations back into msg/messages.js

* Rebuild msg files
2017-06-23 16:54:59 -07:00
RoboErikG
df84c71c66 Convert more text blocks to JSON format (#1163)
* Convert more text blocks to JSON format

Converts text_charAt, text_indexOf, text_isEmpty, and text_length
to JSON.

Includes a rebuild to pick up message changes.
2017-06-12 10:36:36 -07:00
RoboErikG
fa72e02dc5 Convert more text blocks to json (#1147)
* Convert more text blocks to json

Converts the mutator blocks for text_join and the text_append block
to JSON format.
2017-06-01 14:21:16 -07:00
marisaleung
d903b5e86b VariableMap and functions added. 2017-05-03 10:51:24 -07:00
vicng
dfc50ba843 - Changed error message referencing 'procedure' instead of 'function' (#1019)
- Added iOS specific UI messages
- Fixed bug with js_to_json.py script where it didn't recognize ' character
2017-04-06 12:41:09 -07:00
Andrew n marshall
2c349a3152 Update help URL per #937.
Replace URL usages of %28 and %29 with normal parenthesis characters. (They aren't replaced by JavaScript's encodeURIComponent() function, and seem to work just fine without them.)
Added missing semicolon in build.py.
2017-02-28 08:38:37 -08:00
Tim Dawborn
46316c7cea Add a block to reverse a list (#844) 2017-01-21 10:48:42 -08:00
Tim Dawborn
34750bccd8 New blocks text_count, text_replace, and text_reverse (#830)
Includes generators for all languages and units tests on those generators.
2017-01-20 16:08:27 -08:00
Andrew n marshall
560d373c93 Adding support for untranslated messages. (#819)
This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms.

Template details: https://translatewiki.net/wiki/Template:Notranslate
2017-01-13 15:32:00 -08:00
Andrew n marshall
98dc0ed344 Integrating qqq.json changes into messages.json. (#820)
From commits b77f8cbebc and 4ecdedec9f
2017-01-12 15:31:11 -08:00
Rachel Fenichel
82261e3d68 Remove ifelse block and messages' 2016-11-11 17:21:29 -08:00