Skip to content

Commit d099bd6

Browse files
authored
Fix comment form textarea with multiple labels issue (#113)
1 parent ea1b5cf commit d099bd6

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

client-participation/js/templates/comment-form.handlebars

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626

2727
{{#if hideHelp}}
2828
{{!-- even if help text is hidden, still screen read the main comment box label/prompt --}}
29-
<label for="comment_form_textarea"
30-
style="display:none;">
29+
<label id="writeCommentHelpText"
30+
class="screen-reader-text">
3131
{{{s.writeCommentHelpText}}}
3232
</label>
3333
{{else}}
34-
<label for="comment_form_textarea"
34+
<label id="writeCommentHelpText"
3535
style="display:block;">
3636
{{{s.writeCommentHelpText}}}
3737
</label>
@@ -43,9 +43,9 @@
4343
<li>{{{s.helpWriteListRaisNew}}}</li>
4444
<li>{{{s.helpWriteListShort}}}</li>
4545
</ul>
46-
<label for="comment_form_textarea" style="display:block">
46+
<p id="tipCommentsRandom" style="display:block">
4747
{{{s.tipCommentsRandom}}}
48-
</label>
48+
</p>
4949
{{/if}}
5050

5151
{{!-- end screen-reader-text --}}
@@ -54,9 +54,11 @@
5454
{{!-- present all hints to screen reader --}}
5555
<div class="screen-reader-text">
5656
<h2>{{s.commentWritingTipsHintsHeader}}</h2>
57-
<label for="comment_form_textarea" style="display:block">{{charLimitString}}</label>
58-
<label for="comment_form_textarea" style="display:block">{{s.tipNoQuestions}}</label>
59-
<label for="comment_form_textarea" style="display:block">{{s.tipOneIdea}}</label>
57+
<ul>
58+
<li id="charLimitString" style="display:block">{{charLimitString}}</li>
59+
<li id="tipNoQuestions" style="display:block">{{s.tipNoQuestions}}</li>
60+
<li id="tipOneIdea" style="display:block">{{s.tipOneIdea}}</li>
61+
</ul>
6062
</div> {{!-- end screen-reader-text --}}
6163

6264

@@ -131,6 +133,8 @@
131133
name="txt"
132134
type="text"
133135
maxlength="400"
136+
aria-labelledby="writeCommentHelpText"
137+
aria-describedby="{{#unless hideHelp}}tipCommentsRandom {{/unless}}charLimitString tipNoQuestions tipOneIdea commentCharCountExceededContainer"
134138
{{!-- placeholder="Submit your own opinions here. Shorter is better - break up your ideas. You are not responding to anyone else directly - comments are sent out randomly to all participants." --}}
135139
placeholder="{{s.writePrompt}}"
136140
{{#if shouldAutofocusOnTextarea}}autofocus{{/if}}
@@ -211,13 +215,14 @@
211215
style="display: none; color: gray; {{#if desktop}}min-width: 20px;{{/if}}"
212216
class="comment_form_control_hideable unselectable">
213217
</span>
214-
<label
215-
id="commentCharCountExceeded"
216-
for="comment_form_textarea"
217-
role="alert"
218-
style="display: none; color: red; {{#if desktop}}min-width: 20px;{{/if}}"
219-
class="comment_form_control_hideable unselectable">
220-
</label>
218+
<span id="commentCharCountExceededContainer">
219+
<span
220+
id="commentCharCountExceeded"
221+
role="alert"
222+
style="display: none; color: red; {{#if desktop}}min-width: 20px;{{/if}}"
223+
class="comment_form_control_hideable unselectable">
224+
</span>
225+
</span>
221226
<button
222227
class="
223228
Btn

0 commit comments

Comments
 (0)