Commit 0d1b20e0 by Matjaz Gregoric

Remove aria-live attribute from feedback regions.

We are now using SR.readText function to prompt the screen reader to
read feedback messages, so there is no need to use aria-live, which was
sometimes conflicting with SR.readText.
parent ea3b1534
...@@ -249,7 +249,7 @@ function DragAndDropTemplates(configuration) { ...@@ -249,7 +249,7 @@ function DragAndDropTemplates(configuration) {
h('div.feedback', {attributes: {'role': 'group', 'aria-label': gettext('Feedback')}}, [ h('div.feedback', {attributes: {'role': 'group', 'aria-label': gettext('Feedback')}}, [
h( h(
"div.feedback-content", "div.feedback-content",
{attributes: {'aria-live': 'polite', 'aria-atomic': 'true', 'aria-relevant': 'all'}}, {},
[ [
h('h3.title1', { style: { display: feedback_display } }, gettext('Feedback')), h('h3.title1', { style: { display: feedback_display } }, gettext('Feedback')),
h('div.messages', { style: { display: feedback_display } }, feedback_messages), h('div.messages', { style: { display: feedback_display } }, feedback_messages),
...@@ -408,12 +408,7 @@ function DragAndDropTemplates(configuration) { ...@@ -408,12 +408,7 @@ function DragAndDropTemplates(configuration) {
popupSelector, popupSelector,
{ {
style: {display: have_messages ? 'block' : 'none'}, style: {display: have_messages ? 'block' : 'none'},
attributes: { attributes: {"tabindex": "-1"}
"tabindex": "-1",
'aria-live': 'polite',
'aria-atomic': 'true',
'aria-relevant': 'all',
}
}, },
[ [
h( h(
...@@ -501,7 +496,7 @@ function DragAndDropTemplates(configuration) { ...@@ -501,7 +496,7 @@ function DragAndDropTemplates(configuration) {
return h('div.problem-progress', { return h('div.problem-progress', {
id: configuration.url_name + '-problem-progress', id: configuration.url_name + '-problem-progress',
attributes: {'role': 'status', 'aria-live': 'polite'} attributes: {role: 'status'}
}, progress_text); }, progress_text);
}; };
...@@ -883,7 +878,6 @@ function DragAndDropBlock(runtime, element, configuration) { ...@@ -883,7 +878,6 @@ function DragAndDropBlock(runtime, element, configuration) {
var applyState = function(keepDraggableInit) { var applyState = function(keepDraggableInit) {
sendFeedbackPopupEvents(); sendFeedbackPopupEvents();
updateDOM(); updateDOM();
readScreenReaderMessages();
if (!keepDraggableInit) { if (!keepDraggableInit) {
destroyDraggable(); destroyDraggable();
if (!state.finished) { if (!state.finished) {
...@@ -930,7 +924,7 @@ function DragAndDropBlock(runtime, element, configuration) { ...@@ -930,7 +924,7 @@ function DragAndDropBlock(runtime, element, configuration) {
// Uses edX JS accessibility tools to read feedback messages when present. // Uses edX JS accessibility tools to read feedback messages when present.
var readScreenReaderMessages = function() { var readScreenReaderMessages = function() {
if (window.SR && window.SR.readText && window.SR.clear) { if (window.SR && window.SR.readText) {
var pluckMessages = function(feedback_items) { var pluckMessages = function(feedback_items) {
return feedback_items.map(function(item) { return feedback_items.map(function(item) {
return item.message; return item.message;
...@@ -948,7 +942,7 @@ function DragAndDropBlock(runtime, element, configuration) { ...@@ -948,7 +942,7 @@ function DragAndDropBlock(runtime, element, configuration) {
if (state.feedback && configuration.mode === DragAndDropBlock.ASSESSMENT_MODE) { if (state.feedback && configuration.mode === DragAndDropBlock.ASSESSMENT_MODE) {
if (state.feedback.length > 0) { if (state.feedback.length > 0) {
if (!state.last_action_correct) { if (!state.last_action_correct) {
messages.push(gettext("Some of your answers were not correct.")) messages.push(gettext("Some of your answers were not correct."));
} }
messages = messages.concat( messages = messages.concat(
gettext("Hints:"), gettext("Hints:"),
...@@ -956,8 +950,6 @@ function DragAndDropBlock(runtime, element, configuration) { ...@@ -956,8 +950,6 @@ function DragAndDropBlock(runtime, element, configuration) {
); );
} }
} }
SR.clear();
SR.readText(messages.join('\n')); SR.readText(messages.join('\n'));
} }
}; };
...@@ -1266,6 +1258,7 @@ function DragAndDropBlock(runtime, element, configuration) { ...@@ -1266,6 +1258,7 @@ function DragAndDropBlock(runtime, element, configuration) {
state.finished = true; state.finished = true;
state.overall_feedback = data.overall_feedback; state.overall_feedback = data.overall_feedback;
} }
readScreenReaderMessages();
} }
applyState(); applyState();
if (state.feedback && state.feedback.length > 0) { if (state.feedback && state.feedback.length > 0) {
...@@ -1370,6 +1363,7 @@ function DragAndDropBlock(runtime, element, configuration) { ...@@ -1370,6 +1363,7 @@ function DragAndDropBlock(runtime, element, configuration) {
} else { } else {
state.finished = true; state.finished = true;
} }
readScreenReaderMessages();
}).always(function() { }).always(function() {
state.submit_spinner = false; state.submit_spinner = false;
applyState(); applyState();
......
...@@ -173,7 +173,6 @@ class BaseIntegrationTest(SeleniumBaseTest): ...@@ -173,7 +173,6 @@ class BaseIntegrationTest(SeleniumBaseTest):
""" """
window.SR = { window.SR = {
received_texts: [], received_texts: [],
clear: function() {},
readText: function(text) { readText: function(text) {
window.SR.received_texts.push(text); window.SR.received_texts.push(text);
} }
......
...@@ -203,12 +203,10 @@ class TestDragAndDropRender(BaseIntegrationTest): ...@@ -203,12 +203,10 @@ class TestDragAndDropRender(BaseIntegrationTest):
self.load_scenario() self.load_scenario()
popup = self._get_popup() popup = self._get_popup()
popup_wrapper = self._get_popup_wrapper()
popup_content = self._get_popup_content() popup_content = self._get_popup_content()
self.assertFalse(popup.is_displayed()) self.assertFalse(popup.is_displayed())
self.assertIn('popup', popup.get_attribute('class')) self.assertIn('popup', popup.get_attribute('class'))
self.assertEqual(popup_content.text, "") self.assertEqual(popup_content.text, "")
self.assertEqual(popup_wrapper.get_attribute('aria-live'), 'polite')
@data(None, Keys.RETURN) @data(None, Keys.RETURN)
def test_go_to_beginning_button(self, action_key): def test_go_to_beginning_button(self, action_key):
...@@ -252,9 +250,7 @@ class TestDragAndDropRender(BaseIntegrationTest): ...@@ -252,9 +250,7 @@ class TestDragAndDropRender(BaseIntegrationTest):
def test_feedback(self): def test_feedback(self):
self.load_scenario() self.load_scenario()
feedback = self._get_feedback()
feedback_message = self._get_feedback_message() feedback_message = self._get_feedback_message()
self.assertEqual(feedback.get_attribute('aria-live'), 'polite')
self.assertEqual(feedback_message.text, START_FEEDBACK) self.assertEqual(feedback_message.text, START_FEEDBACK)
def test_background_image(self): def test_background_image(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment