Clean up labelling in the Discussion Add Post form
Location: 06 Discussion - Add Post
Description: The radio buttons Question and Discussion are implemented with proper label with a for attribute that corresponds to the ID of the field, a fieldset and legend for the question, and aria-describedby for the hint. However, the entire container is also within a label element. JAWS does not render the radio buttons labels as expected.
Similarly, the Topic area combo box is not properly labeled which makes JAWS render the label and the hint in a non optimal manner.
Auditor Note: Developers must ensure that the structure of the labels for the form fields are appropriate to ensure that assistive technologies render the labels properly as expected. In this case, remove the label element as a parent container and ensure only the visual labels have the label element around them with the proper for attribute that corresponds to the ID of the fields. The hidden fieldset and legend for the radio buttons are not necessary if the on-screen labels are implemented with fieldset and legend elements.
<div class="field-help" id="field_help_post_type">
Questions raise issues that need answers. Discussions share ideas and start conversations. (Required)
<label for="form-12-post-type-question" class="post-type-label">
<input aria-describedby="field_help_post_type" name="form-12-post-type" class="field-input input-radio" id="form-12-post-type-question" value="question" type="radio">
<span class="icon fa fa-question" aria-hidden="true"></span>
Compliant example for Topic area combo box:
<label for="topic" class="field-label-text">
<div class="field-help" id="field_help_topic_area">
Add your post to a relevant topic to help others find it. (Required)
<select id="topic" class="post-topic field-input" aria-describedby="field_help_topic_area" required="">
Compliant Example for the Post Type Radio buttons:
Internal Note: I have a feeling we did not have the option of implementing this correctly which is why we implemented this fairly hacky solution. If this is the case, we should at the very least remove the label element on the visual Post type label and leave the SR only one. I also agree that we should use explicit labelling for the Topic area since the help text is both a label and a description.