Skip to content

Commit 7dcd906

Browse files
CopilotLiNk-NY
andcommitted
Implement accessibility improvements for screen readers on Ask a Question page
Co-authored-by: LiNk-NY <[email protected]>
1 parent 3728775 commit 7dcd906

File tree

4 files changed

+77
-5
lines changed

4 files changed

+77
-5
lines changed

biostar/forum/forms.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,12 @@ class PostLongForm(forms.Form):
168168
choices = informative_choices(choices=choices)
169169

170170
post_type = forms.IntegerField(label="Post Type",
171-
widget=forms.Select(choices=choices, attrs={'class': "ui dropdown"}),
171+
widget=forms.Select(choices=choices, attrs={
172+
'class': "ui dropdown",
173+
'aria-label': "Select post type",
174+
'aria-required': "true",
175+
'aria-describedby': "post_type_help"
176+
}),
172177
help_text="Select a post type.")
173178
title = forms.CharField(label="Post Title", max_length=200, min_length=2,
174179
validators=[valid_title, validate_ascii],

biostar/forum/templates/new_post.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<div class="required field">
4242
<label>{{ form.post_type.label }}</label>
4343
{{ form.post_type }}
44-
<p class="muted" style="display: contents; ">{{ form.post_type.help_text }} Click here for
44+
<p class="muted" id="post_type_help" style="display: contents; ">{{ form.post_type.help_text }} Click here for
4545
more</p> {% include 'forms/help_text.html' %}
4646
</div>
4747

@@ -51,7 +51,7 @@
5151
{% block new_tag_val %}
5252
{{ form.tag_val }}
5353
{% endblock %}
54-
<p class="muted">{{ form.tag_val.help_text }}</p>
54+
<p class="muted" id="tag_val_help">{{ form.tag_val.help_text }}</p>
5555
</div>
5656

5757

biostar/forum/templatetags/forum_tags.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,12 @@ def inplace_type_field(post=None, field_id='type'):
320320
(opt[0] in Post.TOP_LEVEL), choices)
321321

322322
post_type = forms.IntegerField(label="Post Type",
323-
widget=forms.Select(choices=choices, attrs={'class': "ui fluid dropdown",
324-
'id': field_id}),
323+
widget=forms.Select(choices=choices, attrs={
324+
'class': "ui fluid dropdown",
325+
'id': field_id,
326+
'aria-label': "Select post type",
327+
'aria-required': "true"
328+
}),
325329
help_text="Select a post type.")
326330

327331
value = post.type if post else Post.QUESTION

themes/bioconductor/static/theme.css

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,66 @@ body {
118118
background-color: #87B13F !important;
119119
color: white;
120120
}
121+
122+
/* ========================================
123+
Accessibility improvements for dropdowns
124+
======================================== */
125+
126+
/* Ensure native select elements are accessible when JavaScript is disabled */
127+
.ui.dropdown select {
128+
opacity: 1 !important;
129+
position: static !important;
130+
height: auto !important;
131+
width: 100% !important;
132+
visibility: visible !important;
133+
}
134+
135+
/* Style native selects to look consistent */
136+
.ui.dropdown.disabled select,
137+
noscript .ui.dropdown select {
138+
display: block !important;
139+
opacity: 1 !important;
140+
position: static !important;
141+
height: auto !important;
142+
width: 100% !important;
143+
visibility: visible !important;
144+
background: white;
145+
border: 1px solid rgba(34,36,38,.15);
146+
border-radius: .28571429rem;
147+
padding: .67857143em 1em;
148+
font-size: 1em;
149+
line-height: 1.21428571em;
150+
}
151+
152+
/* Hide the custom dropdown UI when JavaScript is disabled */
153+
noscript .ui.dropdown .text,
154+
noscript .ui.dropdown .dropdown.icon {
155+
display: none !important;
156+
}
157+
158+
/* Ensure focus is visible on all interactive elements */
159+
.ui.dropdown:focus,
160+
.ui.dropdown select:focus {
161+
outline: 2px solid #0066cc;
162+
outline-offset: 2px;
163+
}
164+
165+
/* Improve screen reader announcements */
166+
.sr-only {
167+
position: absolute;
168+
left: -10000px;
169+
width: 1px;
170+
height: 1px;
171+
overflow: hidden;
172+
}
173+
174+
/* Ensure form validation messages are accessible */
175+
.field .error.message {
176+
color: #9f3a38;
177+
font-weight: 600;
178+
}
179+
180+
.field .error.message:before {
181+
content: "Error: ";
182+
font-weight: bold;
183+
}

0 commit comments

Comments
 (0)