mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
feat: Add verbosity shortcuts (experimental) (#9481)
## The basics
- [x] I [validated my changes](https://developers.google.com/blockly/guides/contribute/core#making_and_verifying_a_change)
## The details
### Resolves
Fixes part of https://github.com/RaspberryPiFoundation/blockly-keyboard-experimentation/issues/764
Fixes part of #9450 (infrastructure needs)
### Proposed Changes
Introduces support for two new "where am I?" shortcuts for helping to provide location context for users:
- `I`: re-reads the current selected block with full verbosity (i.e. also includes the block's field types with their values in the readout).
- `shift+I`: reads the current selected block's parent with full verbosity.
Note that this includes some functional changes to `Field` to allow for more powerful customization of a field's ARIA representation (by splitting up value and type), though a field's value defaults potentially to null which will be ignored in the final ARIA computed label. This seems necessary per the discussion here: https://github.com/RaspberryPiFoundation/blockly/pull/9470/files#r2541508565 but more consideration may be needed here as part of #9307.
Some limitations in the new shortcuts:
- They will not read out anything if a block is not selected (e.g. for fields and icons).
- They read out input blocks when the input block is selected.
- They cannot read out anything while in move mode (due to the behavior here in the plugin which automatically cancels moves if an unknown shortcut is pressed: a36f3662b0/src/actions/mover.ts (L166-L191)).
- The readout is limited by the problems of dynamic ARIA announcements (per #9460).
### Reason for Changes
https://github.com/RaspberryPiFoundation/blockly-keyboard-experimentation/issues/764 provides context on the specific needs addressed here.
### Test Coverage
Self tested. No new automated tests needed for experimental work.
### Documentation
No new documentation needed for experimental work.
### Additional Information
This was spun out of #9470 with the intent of getting shortcuts initially working checked in even if the entirety of the experience is incomplete.
This commit is contained in:
@@ -116,10 +116,18 @@ export class FieldCheckbox extends Field<CheckboxBool> {
|
||||
this.recomputeAria();
|
||||
}
|
||||
|
||||
override getAriaValue(): string {
|
||||
return this.value_ ? 'checked' : 'not checked';
|
||||
}
|
||||
|
||||
private recomputeAria() {
|
||||
const element = this.getFocusableElement();
|
||||
aria.setRole(element, aria.Role.CHECKBOX);
|
||||
aria.setState(element, aria.State.LABEL, this.getAriaName() ?? 'Checkbox');
|
||||
aria.setState(
|
||||
element,
|
||||
aria.State.LABEL,
|
||||
this.getAriaTypeName() ?? 'Checkbox',
|
||||
);
|
||||
aria.setState(element, aria.State.CHECKED, !!this.value_);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user