Skip to content

Commit 6e06bbe

Browse files
fix: Keep workspace stack count fresh instead of hiding it on Apple (#9885)
Screen readers read the workspace's region label when its contents are focused, but updateAriaLabel only ran on the workspace node's own focus. When a child block took focus on first entry the label was never refreshed, so a stale stack count (e.g. "0 stacks") was announced. The previous workaround dropped the count entirely on Apple. Refresh the label in onTreeFocus, which fires whenever focus enters the workspace tree (including via a child), before the element is focused, so the announced count is current. This lets us restore the informative stack count on all platforms.
1 parent f466d4d commit 6e06bbe

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

packages/blockly/core/workspace_svg.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -745,17 +745,6 @@ export class WorkspaceSvg
745745
* Updates the label on the workspace to reflect the number of top-level stacks in the workspace.
746746
*/
747747
private updateAriaLabel() {
748-
if (userAgent.APPLE) {
749-
// VoiceOver is reading this label inappropriately, so don't show the
750-
// stack count because it might be inaccurate.
751-
// https://github.com/RaspberryPiFoundation/blockly/issues/9885
752-
aria.setState(
753-
this.svgGroup_,
754-
aria.State.LABEL,
755-
Msg['WORKSPACE_LABEL_PLAIN'],
756-
);
757-
return;
758-
}
759748
const numStacks = this.getTopBlocks(false).length;
760749
if (numStacks == 1) {
761750
aria.setState(
@@ -2975,7 +2964,14 @@ export class WorkspaceSvg
29752964
onTreeFocus(
29762965
_node: IFocusableNode,
29772966
_previousTree: IFocusableTree | null,
2978-
): void {}
2967+
): void {
2968+
// Screen readers read this label as the enclosing region when workspace
2969+
// contents are focused, so refresh it here to keep the stack count from
2970+
// going stale.
2971+
if (!this.isFlyout && !this.isMutator) {
2972+
this.updateAriaLabel();
2973+
}
2974+
}
29792975

29802976
/** See IFocusableTree.onTreeBlur. */
29812977
onTreeBlur(nextTree: IFocusableTree | null): void {

0 commit comments

Comments
 (0)