From 222bea3abcaf4bab964bb4670869366401c02b56 Mon Sep 17 00:00:00 2001 From: JooYoung Seo Date: Fri, 20 Sep 2024 09:53:57 -0500 Subject: [PATCH] Revert "refactor: add aria-label to maidr area" (#561) --- .vscode/extensions.json | 3 +-- galleries/bar_plot.html | 1 + galleries/scatterplot.html | 1 + src/js/controls.js | 12 ++++-------- src/js/init.js | 16 +++++++++------- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 9fa3d617..d578a543 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -21,8 +21,7 @@ // "codium.codium", "ms-vscode.vscode-speech", "vivaxy.vscode-conventional-commits", - "joshbolduc.commitlint", - "ms-vscode.live-server" + "joshbolduc.commitlint" ], "unwantedRecommendations": ["ms-vscode.js-debug"] } diff --git a/galleries/bar_plot.html b/galleries/bar_plot.html index 34602085..74d28626 100644 --- a/galleries/bar_plot.html +++ b/galleries/bar_plot.html @@ -1134,6 +1134,7 @@ id: 'barplot1', title: 'The Number of Diamonds by Cut.', selector: 'g[id^="geom_rect"] > rect', + name: 'test test test', axes: { x: { label: 'Cut', diff --git a/galleries/scatterplot.html b/galleries/scatterplot.html index 760750e8..a51fb594 100644 --- a/galleries/scatterplot.html +++ b/galleries/scatterplot.html @@ -4594,6 +4594,7 @@ 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"]', diff --git a/src/js/controls.js b/src/js/controls.js index c83f6798..b54a364f 100644 --- a/src/js/controls.js +++ b/src/js/controls.js @@ -2392,18 +2392,14 @@ class Control { if (position.x > xMax) { position.x = xMax; didLockHappen = true; - if ( constants.brailleMode != 'off' ) { - constants.brailleInput.selectionStart = - constants.brailleInput.value.length; - } + constants.brailleInput.selectionStart = + constants.brailleInput.value.length; } if (position.y > yMax) { position.y = yMax; didLockHappen = true; - if ( constants.brailleMode != 'off' ) { - constants.brailleInput.selectionStart = - constants.brailleInput.value.length; - } + constants.brailleInput.selectionStart = + constants.brailleInput.value.length; } } return didLockHappen; diff --git a/src/js/init.js b/src/js/init.js index ac581df1..fde56f07 100644 --- a/src/js/init.js +++ b/src/js/init.js @@ -112,13 +112,15 @@ function InitMaidr(thisMaidr) { // actually do eventlisteners for all events this.SetEvents(); - // 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.`); - } + // 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); } }