Merge pull request #14298 from edx/jlajoie/TNL-6095
Adds trailing_text id to input describedby
This commit is contained in:
@@ -328,9 +328,16 @@ class InputTypeBase(object):
|
||||
}
|
||||
|
||||
# Generate the list of ids to be used with the aria-describedby field.
|
||||
descriptions = list()
|
||||
|
||||
# If there is trailing text, add the id as the first element to the list before adding the status id
|
||||
if 'trailing_text' in self.loaded_attributes and self.loaded_attributes['trailing_text']:
|
||||
trailing_text_id = 'trailing_text_' + self.input_id
|
||||
descriptions.append(trailing_text_id)
|
||||
|
||||
# Every list should contain the status id
|
||||
status_id = 'status_' + self.input_id
|
||||
descriptions = list([status_id])
|
||||
descriptions.append(status_id)
|
||||
descriptions.extend(self.response_data.get('descriptions', {}).keys())
|
||||
description_ids = ' '.join(descriptions)
|
||||
context.update(
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
size="${size}"
|
||||
% endif
|
||||
/>
|
||||
<span class="trailing_text">${trailing_text}</span>
|
||||
<span class="trailing_text" id="trailing_text_${id}">${trailing_text}</span>
|
||||
|
||||
<%include file="status_span.html" args="status=status, status_id=id"/>
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
style="display:none;"
|
||||
% endif
|
||||
/>
|
||||
<span class="trailing_text">${trailing_text}</span>
|
||||
<span class="trailing_text" id="trailing_text_${id}">${trailing_text}</span>
|
||||
|
||||
<%include file="status_span.html" args="status=status, status_id=id"/>
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ lookup_tag = inputtypes.registry.get_class_for_tag
|
||||
|
||||
|
||||
DESCRIBEDBY = HTML('aria-describedby="status_{status_id} desc-1 desc-2"')
|
||||
# Use TRAILING_TEXT_DESCRIBEDBY when trailing_text is not null
|
||||
TRAILING_TEXT_DESCRIBEDBY = HTML('aria-describedby="trailing_text_{trailing_text_id} status_{status_id} desc-1 desc-2"')
|
||||
DESCRIPTIONS = OrderedDict([('desc-1', 'description text 1'), ('desc-2', 'description text 2')])
|
||||
RESPONSE_DATA = {
|
||||
'label': 'question text 101',
|
||||
@@ -361,7 +363,7 @@ class TextLineTest(unittest.TestCase):
|
||||
'trailing_text': expected_text,
|
||||
'preprocessor': None,
|
||||
'response_data': RESPONSE_DATA,
|
||||
'describedby_html': DESCRIBEDBY.format(status_id=prob_id)
|
||||
'describedby_html': TRAILING_TEXT_DESCRIBEDBY.format(trailing_text_id=prob_id, status_id=prob_id)
|
||||
}
|
||||
self.assertEqual(context, expected)
|
||||
|
||||
@@ -1295,7 +1297,7 @@ class FormulaEquationTest(unittest.TestCase):
|
||||
'inline': False,
|
||||
'trailing_text': expected_text,
|
||||
'response_data': RESPONSE_DATA,
|
||||
'describedby_html': DESCRIBEDBY.format(status_id=prob_id)
|
||||
'describedby_html': TRAILING_TEXT_DESCRIBEDBY.format(trailing_text_id=prob_id, status_id=prob_id)
|
||||
}
|
||||
|
||||
self.assertEqual(context, expected)
|
||||
|
||||
Reference in New Issue
Block a user