Skip to content

Commit 07c83d3

Browse files
dejoskimikeharv
andauthored
chore: use none ARIA role consistently instead of presentation (#10067)
* fix: use none ARIA role consistently Signed-off-by: Dejan Stajic <8886210+dejoski@users.noreply.github.com> * chore: Reorder role definitions in aria.ts --------- Signed-off-by: Dejan Stajic <8886210+dejoski@users.noreply.github.com> Co-authored-by: Dejan Stajic <8886210+dejoski@users.noreply.github.com> Co-authored-by: Michael Harvey <43474485+mikeharv@users.noreply.github.com>
1 parent 793453c commit 07c83d3

12 files changed

Lines changed: 24 additions & 24 deletions

File tree

packages/blockly/core/block_aria_composer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function computeAriaLabel(
8787
* @param block The block to set ARIA role and roledescription attributes on.
8888
*/
8989
export function configureAriaRole(block: BlockSvg) {
90-
setRole(block.getSvgRoot(), Role.PRESENTATION);
90+
setRole(block.getSvgRoot(), Role.NONE);
9191
const focusableElement = block.getFocusableElement();
9292
if (!block.isInFlyout) {
9393
// blocks in the flyout have their role set by the Flyout's block inflater

packages/blockly/core/block_flyout_inflater.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class BlockFlyoutInflater implements IFlyoutInflater {
7474
// blocks can't be focused if they're in a flyout and not top-level
7575
// nonfocusable blocks should be hidden from the aria tree
7676
aria.setState(focusableElement, aria.State.HIDDEN, true);
77-
aria.setRole(focusableElement, aria.Role.PRESENTATION);
77+
aria.setRole(focusableElement, aria.Role.NONE);
7878
});
7979
// Since getDescencdants includes the root block, we need
8080
// to correct the role and hidden state for it.

packages/blockly/core/field_image.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,11 @@ export class FieldImage extends Field<string> {
364364
const focusableElement = this.getFocusableElement();
365365

366366
// The button role is intended to indicate to users that the field has an
367-
// editing mode that can be activated. The presentation role is used to
367+
// editing mode that can be activated. The none role is used to
368368
// prevent screen readers from reading the content or its descendants.
369369
// Only clickable image fields are navigable.
370370
if (!this.isClickable()) {
371-
aria.setRole(focusableElement, aria.Role.PRESENTATION);
371+
aria.setRole(focusableElement, aria.Role.NONE);
372372
aria.clearState(focusableElement, aria.State.LABEL);
373373
return false;
374374
}

packages/blockly/core/flyout_base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ export abstract class Flyout
683683
if (!this.targetWorkspace.isMutator && !this.autoClose) {
684684
aria.setRole(this.getWorkspace().svgGroup_, aria.Role.REGION);
685685
} else {
686-
aria.setRole(this.getWorkspace().svgGroup_, aria.Role.PRESENTATION);
686+
aria.setRole(this.getWorkspace().svgGroup_, aria.Role.NONE);
687687
}
688688

689689
// the label for a flyout includes the category name if it's available

packages/blockly/core/flyout_button.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export class FlyoutButton
136136
},
137137
this.svgGroup!,
138138
);
139-
aria.setRole(shadow, aria.Role.PRESENTATION);
139+
aria.setRole(shadow, aria.Role.NONE);
140140
}
141141
// Background rectangle.
142142
const rect = dom.createSvgElement(
@@ -150,7 +150,7 @@ export class FlyoutButton
150150
},
151151
this.svgGroup!,
152152
);
153-
aria.setRole(rect, aria.Role.PRESENTATION);
153+
aria.setRole(rect, aria.Role.NONE);
154154

155155
const svgText = dom.createSvgElement(
156156
Svg.TEXT,
@@ -174,7 +174,7 @@ export class FlyoutButton
174174
.getThemeManager()
175175
.subscribe(this.svgText, 'flyoutForegroundColour', 'fill');
176176
}
177-
aria.setRole(svgText, aria.Role.PRESENTATION);
177+
aria.setRole(svgText, aria.Role.NONE);
178178

179179
// We add the word "heading" or "button" to the label so that they give appropriate hints
180180
// we can't use the corresponding roles because that overwrites the context of it being an option.

packages/blockly/core/menuitem.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ export class MenuItem {
7777

7878
const content = document.createElement('div');
7979
aria.setState(element, aria.State.LABEL, this.getAriaLabel());
80-
// The presentation role is used to prevent screen readers from also reading the
80+
// The none role is used to prevent screen readers from also reading the
8181
// content or its descendants.
82-
aria.setRole(content, aria.Role.PRESENTATION);
82+
aria.setRole(content, aria.Role.NONE);
8383
content.className = 'blocklyMenuItemContent';
8484

8585
let contentDom: Node = this.content as HTMLElement;

packages/blockly/core/renderers/zelos/path_object.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class PathObject extends BasePathObject {
9898
'fill': this.svgPath.getAttribute('fill') || '',
9999
'd': this.svgPath.getAttribute('d') || '',
100100
'transform': this.svgPath.getAttribute('transform') || '',
101-
'role': Role.PRESENTATION,
101+
'role': Role.NONE,
102102
},
103103
this.svgRoot,
104104
);

packages/blockly/core/toolbox/category.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export class ToolboxCategory
202202
this.rowDiv_.appendChild(this.rowContents_);
203203

204204
this.iconDom_ = this.createIconDom_();
205-
aria.setRole(this.iconDom_, aria.Role.PRESENTATION);
205+
aria.setRole(this.iconDom_, aria.Role.NONE);
206206
this.rowContents_.appendChild(this.iconDom_);
207207

208208
this.labelDom_ = this.createLabelDom_(this.name_);

packages/blockly/core/utils/aria.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ export enum Role {
8787
MENU = 'menu',
8888
/** See https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/menuitem_role. */
8989
MENUITEM = 'menuitem',
90+
/** See https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/none_role. */
91+
NONE = 'none',
9092
/** See https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/option_role. */
9193
OPTION = 'option',
92-
/** See https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/presentation_role. */
93-
PRESENTATION = 'presentation',
9494
/** See https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/region_role. */
9595
REGION = 'region',
9696
/** See https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/row_role. */

packages/blockly/core/utils/dom.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ export function createSvgElement<T extends SVGElement>(
5858
): T {
5959
const e = document.createElementNS(SVG_NS, `${name}`) as T;
6060
/**
61-
* For svg and group (g) elements, we set the role to presentation so that they are ignored by assistive technologies.
61+
* For svg and group (g) elements, we set the role to none so that they are ignored by assistive technologies.
6262
*/
6363
if (
6464
name === Svg.SVG.toString() ||
6565
name === Svg.G.toString() ||
6666
e.tagName === Svg.SVG.toString() ||
6767
e.tagName === Svg.G.toString()
6868
) {
69-
aria.setRole(e, aria.Role.PRESENTATION);
69+
aria.setRole(e, aria.Role.NONE);
7070
}
7171
for (const key in attrs) {
7272
e.setAttribute(key, `${attrs[key]}`);

0 commit comments

Comments
 (0)