mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Improve A11y of comment reply.
Currently this is a link. Users will expect this link to take them to another part of the page or another page altogether. There is no indication that it opens or closes an associated form on the same page, nor does it indicate the current state of the “reply to” form. So, instead of a link, use a button. Add to that button an aria-controls attribute that references the id of the associated form’s container, and an aria-expanded attribute that indicates (true or false) the state of the associated form.
This commit is contained in:
parent
4bf0a83ad3
commit
ae59e82021
@ -79,20 +79,25 @@
|
||||
* Toggle on/off reply form
|
||||
*/
|
||||
$( ".comment-reply-link" ).entwine({
|
||||
onclick: function( e ) {
|
||||
var allForms = $( ".comment-reply-form-holder" ),
|
||||
formID = $( this ).prop('href').replace(/^[^#]*#/, '#'),
|
||||
onclick: function( e ) {
|
||||
var allForms = $( ".comment-reply-form-holder" ),
|
||||
formID = '#' + $( this ).attr('aria-controls');
|
||||
form = $(formID).closest('.comment-reply-form-holder');
|
||||
|
||||
// Prevent focus
|
||||
e.preventDefault();
|
||||
if(form.is(':visible')) {
|
||||
allForms.slideUp();
|
||||
} else {
|
||||
allForms.not(form).slideUp();
|
||||
$(this).attr('aria-expanded', function (i, attr) {
|
||||
return attr == 'true' ? 'false' : 'true'
|
||||
});
|
||||
|
||||
// Prevent focus
|
||||
e.preventDefault();
|
||||
|
||||
if(form.is(':visible')) {
|
||||
allForms.slideUp();
|
||||
} else {
|
||||
allForms.not(form).slideUp();
|
||||
form.slideDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
@ -33,7 +33,9 @@
|
||||
<% end_if %>
|
||||
</div>
|
||||
<% if $RepliesEnabled && $canPostComment %>
|
||||
<a class="comment-reply-link" href="#{$ReplyForm.FormName}"><% _t('CommentsInterface_singlecomment_ss.REPLYTO','Reply to') %> $AuthorName.XML</a>
|
||||
<button class="comment-reply-link" type="button" aria-controls="$ReplyForm.FormName" aria-expanded="false">
|
||||
+ <% _t('CommentsInterface_singlecomment_ss.REPLYTO','Reply to') %> $AuthorName.XML
|
||||
+ </button>
|
||||
<% end_if %>
|
||||
</div>
|
||||
<% end_if %>
|
||||
|
Loading…
Reference in New Issue
Block a user