Skip to content

Commit 06657a0

Browse files
authored
Merge pull request #1411 from mathjax/issue3493
Have explorer properly handle the tab order menu preference. (mathjax/MathJax#3493)
2 parents a9a3fc0 + c942ea1 commit 06657a0

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

ts/a11y/explorer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ export function ExplorerMathDocumentMixin<
369369
brailleCombine: false, // combine Braille with speech output
370370
help: true, // include "press h for help" messages on focus
371371
roleDescription: 'math', // the role description to use for math expressions
372+
inTabOrder: true, // true if expressin get tabindex = 0
372373
tabSelects: 'all', // 'all' for whole expression, 'last' for last explored node
373374
}
374375
};

ts/a11y/explorer/KeyExplorer.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ export class SpeechExplorer
12771277
if (this.img) {
12781278
this.node.append(this.img);
12791279
}
1280-
this.node.setAttribute('tabindex', '0');
1280+
this.node.setAttribute('tabindex', this.tabIndex);
12811281
}
12821282
}
12831283

@@ -1903,13 +1903,20 @@ export class SpeechExplorer
19031903
this.magnifyRegion.Update(this.current);
19041904
}
19051905

1906+
/**
1907+
* @returns {string} The tabIndex to use when not exploring
1908+
*/
1909+
protected get tabIndex(): string {
1910+
return this.document.options.a11y.inTabOrder ? '0' : '-1';
1911+
}
1912+
19061913
/**
19071914
* @override
19081915
*/
19091916
public Attach() {
19101917
if (this.attached) return;
19111918
super.Attach();
1912-
this.node.setAttribute('tabindex', '0');
1919+
this.node.setAttribute('tabindex', this.tabIndex);
19131920
this.attached = true;
19141921
}
19151922

@@ -1923,7 +1930,7 @@ export class SpeechExplorer
19231930
this.node.removeAttribute('aria-label');
19241931
this.img?.remove();
19251932
if (this.active) {
1926-
this.node.setAttribute('tabindex', '0');
1933+
this.node.setAttribute('tabindex', this.tabIndex);
19271934
}
19281935
this.attached = false;
19291936
}

ts/ui/menu/Menu.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export interface MenuSettings {
8484
autocollapse: boolean;
8585
collapsible: boolean;
8686
enrich: boolean;
87-
inTabOrder: boolean;
8887
assistiveMml: boolean;
8988
// A11y settings
9089
backgroundColor: string;
@@ -99,6 +98,7 @@ export interface MenuSettings {
9998
infoPrefix: boolean;
10099
infoRole: boolean;
101100
infoType: boolean;
101+
inTabOrder: boolean;
102102
locale: string;
103103
magnification: string;
104104
magnify: string;
@@ -153,7 +153,6 @@ export class Menu {
153153
autocollapse: false,
154154
collapsible: false,
155155
enrich: true,
156-
inTabOrder: true,
157156
assistiveMml: false,
158157
speech: true,
159158
braille: true,
@@ -162,6 +161,7 @@ export class Menu {
162161
brailleCombine: false,
163162
speechRules: 'clearspeak-default',
164163
roleDescription: 'math',
164+
inTabOrder: true,
165165
tabSelects: 'all',
166166
help: true,
167167
},
@@ -669,7 +669,7 @@ export class Menu {
669669
this.variable<boolean>('enrich', (enrich) =>
670670
this.setEnrichment(enrich)
671671
),
672-
this.variable<boolean>('inTabOrder', (tab) => this.setTabOrder(tab)),
672+
this.a11yVar<boolean>('inTabOrder', (tab) => this.setTabOrder(tab)),
673673
this.a11yVar<string>('tabSelects'),
674674
this.variable<boolean>('assistiveMml', (mml) =>
675675
this.setAssistiveMml(mml)

0 commit comments

Comments
 (0)