Skip to content

Commit

Permalink
refactor: add aria-label to maidr area (#558)
Browse files Browse the repository at this point in the history
  • Loading branch information
jooyoungseo authored Sep 20, 2024
1 parent 6553aa8 commit ccef83f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
// "codium.codium",
"ms-vscode.vscode-speech",
"vivaxy.vscode-conventional-commits",
"joshbolduc.commitlint"
"joshbolduc.commitlint",
"ms-vscode.live-server"
],
"unwantedRecommendations": ["ms-vscode.js-debug"]
}
1 change: 0 additions & 1 deletion galleries/bar_plot.html
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,6 @@
id: 'barplot1',
title: 'The Number of Diamonds by Cut.',
selector: 'g[id^="geom_rect"] > rect',
name: 'test test test',
axes: {
x: {
label: 'Cut',
Expand Down
1 change: 0 additions & 1 deletion galleries/scatterplot.html
Original file line number Diff line number Diff line change
Expand Up @@ -4594,7 +4594,6 @@
type: ['point', 'smooth'],
id: 'scatter1',
title: 'Highway Mileage by Engine Displacement.',
name: 'Tutorial 4: Scatterplot',
selector: [
'g[id^="geom_point"] > use',
'g[id^="geom_smooth.gTree"] > g[id^="GRID.polyline"] > polyline[id^="GRID.polyline"]',
Expand Down
12 changes: 8 additions & 4 deletions src/js/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -2392,14 +2392,18 @@ class Control {
if (position.x > xMax) {
position.x = xMax;
didLockHappen = true;
constants.brailleInput.selectionStart =
constants.brailleInput.value.length;
if ( constants.brailleMode != 'off' ) {
constants.brailleInput.selectionStart =
constants.brailleInput.value.length;
}
}
if (position.y > yMax) {
position.y = yMax;
didLockHappen = true;
constants.brailleInput.selectionStart =
constants.brailleInput.value.length;
if ( constants.brailleMode != 'off' ) {
constants.brailleInput.selectionStart =
constants.brailleInput.value.length;
}
}
}
return didLockHappen;
Expand Down
16 changes: 7 additions & 9 deletions src/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,13 @@ function InitMaidr(thisMaidr) {
// actually do eventlisteners for all events
this.SetEvents();

// once everything is set up, announce the chart name (or title as a backup) to the user
setTimeout(function () {
// this is hacky, but we delay just a tick so that the chart has time to load
if ('name' in singleMaidr) {
display.announceText(singleMaidr.name);
} else if ('title' in singleMaidr) {
display.announceText(singleMaidr.title);
}
}, 200);
// once everything is set up, expose the chart name (or title as a backup) to the user
if ('name' in singleMaidr) {
constants.chart.setAttribute('aria-label', singleMaidr.name);
} else if ('title' in singleMaidr || 'labels' in singleMaidr && 'title' in singleMaidr.labels) {
let title = 'title' in singleMaidr ? singleMaidr.title : singleMaidr.labels.title;
constants.chart.setAttribute('aria-label', `${singleMaidr.type} plot of ${title}. Use Arrows to navigate data points. Press BTSR to toggle braille, text, sonification, and review mode respectively. Use H key for help.`);
}
}
}

Expand Down

0 comments on commit ccef83f

Please sign in to comment.