Skip to content

Commit 2c3f17c

Browse files
authored
Merge branch 'fix/ff_safari_issues' into sre-menus
2 parents 7ca278e + f5d4f54 commit 2c3f17c

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

ts/a11y/explorer/ExplorerPool.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ export class ExplorerPool {
204204
this.attach();
205205
}
206206

207+
/**
208+
* A11y options keys associated with the speech explorer.
209+
*/
210+
private speechExplorerKeys = ['speech', 'braille', 'keyMagnifier'];
211+
207212
/**
208213
* Attaches the explorers that are currently meant to be active given
209214
* the document options. Detaches all others.
@@ -212,12 +217,19 @@ export class ExplorerPool {
212217
this.attached = [];
213218
let keyExplorers = [];
214219
const a11y = this.document.options.a11y;
215-
for (let key of Object.keys(this.explorers)) {
216-
let explorer = this.explorers[key];
220+
for (let [key, explorer] of Object.entries(this.explorers)) {
217221
if (explorer instanceof SpeechExplorer) {
218222
explorer.AddEvents();
219223
explorer.stoppable = false;
220224
keyExplorers.unshift(explorer);
225+
if (this.speechExplorerKeys.some(
226+
exKey => this.document.options.a11y[exKey])) {
227+
explorer.Attach();
228+
this.attached.push(key);
229+
} else {
230+
explorer.Detach();
231+
}
232+
continue;
221233
}
222234
if (a11y[key] || (key === 'speech' && (a11y.braille || a11y.keyMagnifier))) {
223235
explorer.Attach();

ts/a11y/explorer/KeyExplorer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,8 @@ export class SpeechExplorer extends AbstractExplorer<string> implements KeyExplo
571571
}
572572
}
573573
if (this.active) {
574-
this.stopEvent(event);
575574
if (this.Move(event)) {
575+
this.stopEvent(event);
576576
this.Update();
577577
return;
578578
}
@@ -647,7 +647,8 @@ export class SpeechExplorer extends AbstractExplorer<string> implements KeyExplo
647647
public semanticFocus() {
648648
const node = this.current || this.node;
649649
const id = node.getAttribute('data-semantic-id');
650-
const stree = this.generators.speechGenerator.getRebuilt().stree;
650+
const stree = this.generators.speechGenerator.getRebuilt()?.stree;
651+
if (!stree) return null;
651652
const snode = stree.root.querySelectorAll((x: any) => x.id.toString() === id)[0];
652653
return snode || stree.root;
653654
}

ts/a11y/speech/GeneratorPool.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,17 @@ export class GeneratorPool<N, T, D> {
370370
this.dummyList.forEach(attr => this.copyAttributes(xml, node, attr));
371371
}
372372
}
373-
const speech = this.getLabel(node);
374-
if (speech) {
375-
this.adaptor.setAttribute(node, 'aria-label', buildSpeech(speech, locale)[0]);
373+
if (this.options.a11y.speech) {
374+
const speech = this.getLabel(node);
375+
if (speech) {
376+
this.adaptor.setAttribute(node, 'aria-label', buildSpeech(speech, locale)[0]);
377+
}
376378
}
377-
const braille = this.adaptor.getAttribute(node, 'data-semantic-braille');
378-
if (braille) {
379-
this.adaptor.setAttribute(node, 'aria-braillelabel', braille);
379+
if (this.options.a11y.braille) {
380+
const braille = this.adaptor.getAttribute(node, 'data-semantic-braille');
381+
if (braille) {
382+
this.adaptor.setAttribute(node, 'aria-braillelabel', braille);
383+
}
380384
}
381385
const xmlChildren = Array.from(xml.childNodes);
382386
Array.from(this.adaptor.childNodes(node)).forEach(

0 commit comments

Comments
 (0)