Skip to content

Commit 27fe764

Browse files
authored
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
1 parent 0cc0935 commit 27fe764

File tree

8 files changed

+18
-8
lines changed

8 files changed

+18
-8
lines changed

core/bubbles/bubble.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ export abstract class Bubble implements IBubble, ISelectable, IFocusableNode {
144144
this.focusableElement = overriddenFocusableElement ?? this.svgRoot;
145145
this.focusableElement.setAttribute('id', this.id);
146146
aria.setRole(this.focusableElement, aria.Role.GROUP);
147-
aria.setState(this.focusableElement, aria.State.LABEL, 'Bubble');
148147

149148
browserEvents.conditionalBind(
150149
this.background,

core/comments/collapse_comment_bar_button.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import * as browserEvents from '../browser_events.js';
8+
import {Msg} from '../msg.js';
89
import * as touch from '../touch.js';
910
import * as aria from '../utils/aria.js';
1011
import * as dom from '../utils/dom.js';
@@ -57,6 +58,7 @@ export class CollapseCommentBarButton extends CommentBarButton {
5758
},
5859
this.container,
5960
);
61+
this.initAria();
6062
this.bindId = browserEvents.conditionalBind(
6163
this.icon,
6264
'pointerdown',
@@ -74,7 +76,7 @@ export class CollapseCommentBarButton extends CommentBarButton {
7476

7577
override initAria(): void {
7678
aria.setRole(this.icon, aria.Role.BUTTON);
77-
aria.setState(this.icon, aria.State.LABEL, 'DoNotDefine?');
79+
aria.setState(this.icon, aria.State.LABEL, Msg['COLLAPSE_COMMENT']);
7880
}
7981

8082
/**

core/comments/comment_editor.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export class CommentEditor implements IFocusableNode {
5858
this.textArea.setAttribute('tabindex', '-1');
5959
this.textArea.setAttribute('dir', this.workspace.RTL ? 'RTL' : 'LTR');
6060
aria.setRole(this.textArea, aria.Role.TEXTBOX);
61-
aria.setState(this.textArea, aria.State.LABEL, 'DoNotDefine?');
6261
dom.addClass(this.textArea, 'blocklyCommentText');
6362
dom.addClass(this.textArea, 'blocklyTextarea');
6463
dom.addClass(this.textArea, 'blocklyText');

core/comments/comment_view.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ export class CommentView implements IRenderedElement {
109109
'class': 'blocklyComment blocklyEditable blocklyDraggable',
110110
});
111111

112-
aria.setRole(this.svgRoot, aria.Role.TEXTBOX);
113-
aria.setState(this.svgRoot, aria.State.LABEL, 'DoNotOverride?');
114-
115112
this.highlightRect = this.createHighlightRect(this.svgRoot);
116113

117114
({
@@ -127,6 +124,12 @@ export class CommentView implements IRenderedElement {
127124

128125
this.resizeHandle = this.createResizeHandle(this.svgRoot, workspace);
129126

127+
aria.setRole(this.svgRoot, aria.Role.BUTTON);
128+
if (this.commentEditor.id) {
129+
aria.setState(this.svgRoot, aria.State.LABELLEDBY, this.commentEditor.id);
130+
}
131+
aria.setState(this.svgRoot, aria.State.ROLEDESCRIPTION, 'Comment');
132+
130133
// TODO: Remove this comment before merging.
131134
// I think we want comments to exist on the same layer as blocks.
132135
workspace.getLayerManager()?.append(this, layers.BLOCK);

core/comments/delete_comment_bar_button.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import * as browserEvents from '../browser_events.js';
88
import {getFocusManager} from '../focus_manager.js';
9+
import {Msg} from '../msg.js';
910
import * as touch from '../touch.js';
1011
import * as aria from '../utils/aria.js';
1112
import * as dom from '../utils/dom.js';
@@ -57,6 +58,7 @@ export class DeleteCommentBarButton extends CommentBarButton {
5758
},
5859
container,
5960
);
61+
this.initAria();
6062
this.bindId = browserEvents.conditionalBind(
6163
this.icon,
6264
'pointerdown',
@@ -74,7 +76,7 @@ export class DeleteCommentBarButton extends CommentBarButton {
7476

7577
override initAria(): void {
7678
aria.setRole(this.icon, aria.Role.BUTTON);
77-
aria.setState(this.icon, aria.State.LABEL, 'DoNotDefine?');
79+
aria.setState(this.icon, aria.State.LABEL, Msg['REMOVE_COMMENT']);
7880
}
7981

8082
/**

msg/json/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"@metadata": {
33
"author": "Ellen Spertus <[email protected]>",
4-
"lastupdated": "2025-09-08 16:26:57.642330",
4+
"lastupdated": "2025-09-09 09:40:56.729862",
55
"locale": "en",
66
"messagedocumentation" : "qqq"
77
},
@@ -12,6 +12,7 @@
1212
"ADD_COMMENT": "Add Comment",
1313
"REMOVE_COMMENT": "Remove Comment",
1414
"DUPLICATE_COMMENT": "Duplicate Comment",
15+
"COLLAPSE_COMMENT": "Collapse Comment",
1516
"EXTERNAL_INPUTS": "External Inputs",
1617
"INLINE_INPUTS": "Inline Inputs",
1718
"DELETE_BLOCK": "Delete Block",

msg/json/qqq.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"ADD_COMMENT": "context menu - Add a descriptive comment to the selected block.",
2020
"REMOVE_COMMENT": "context menu - Remove the descriptive comment from the selected block.",
2121
"DUPLICATE_COMMENT": "context menu - Make a copy of the selected workspace comment.\n{{Identical|Duplicate}}",
22+
"COLLAPSE_COMMENT": "context menu - Collapse the selected workspace comment.",
2223
"EXTERNAL_INPUTS": "context menu - Change from 'external' to 'inline' mode for displaying blocks used as inputs to the selected block. See [[Translating:Blockly#context_menus]].\n\nThe opposite of {{msg-blockly|INLINE INPUTS}}.",
2324
"INLINE_INPUTS": "context menu - Change from 'internal' to 'external' mode for displaying blocks used as inputs to the selected block. See [[Translating:Blockly#context_menus]].\n\nThe opposite of {{msg-blockly|EXTERNAL INPUTS}}.",
2425
"DELETE_BLOCK": "context menu - Permanently delete the selected block.",

msg/messages.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ Blockly.Msg.REMOVE_COMMENT = 'Remove Comment';
8585
/// context menu - Make a copy of the selected workspace comment.\n{{Identical|Duplicate}}
8686
Blockly.Msg.DUPLICATE_COMMENT = 'Duplicate Comment';
8787
/** @type {string} */
88+
/// context menu - Collapse the selected workspace comment.
89+
Blockly.Msg.COLLAPSE_COMMENT = 'Collapse Comment';
90+
/** @type {string} */
8891
/// context menu - Change from 'external' to 'inline' mode for displaying blocks used as inputs to the selected block. See [[Translating:Blockly#context_menus]].\n\nThe opposite of {{msg-blockly|INLINE INPUTS}}.
8992
Blockly.Msg.EXTERNAL_INPUTS = 'External Inputs';
9093
/** @type {string} */

0 commit comments

Comments
 (0)