diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php
index 5070b9480e..14e743ccb3 100644
--- a/src/wp-admin/includes/class-wp-comments-list-table.php
+++ b/src/wp-admin/includes/class-wp-comments-list-table.php
@@ -635,7 +635,7 @@ if ( ( 'spam' === $comment_status || 'trash' === $comment_status ) && current_us
if ( 'spam' !== $the_comment_status && 'trash' !== $the_comment_status ) {
$actions['edit'] = "" . __( 'Edit' ) . '';
- $format = '%s';
+ $format = '';
$actions['quickedit'] = sprintf( $format, $comment->comment_ID, $comment->comment_post_ID, 'edit', 'vim-q comment-inline', esc_attr__( 'Quick edit this comment inline' ), __( 'Quick Edit' ) );
diff --git a/src/wp-admin/js/edit-comments.js b/src/wp-admin/js/edit-comments.js
index b9a9f2cf85..0b0d0846bc 100644
--- a/src/wp-admin/js/edit-comments.js
+++ b/src/wp-admin/js/edit-comments.js
@@ -632,15 +632,37 @@ commentReply = {
},
close : function() {
- var c, replyrow = $('#replyrow');
+ var commentRow = $(),
+ replyRow = $( '#replyrow' );
// replyrow is not showing?
- if ( replyrow.parent().is('#com-reply') )
+ if ( replyRow.parent().is( '#com-reply' ) ) {
return;
+ }
- if ( this.cid && this.act == 'edit-comment' ) {
- c = $('#comment-' + this.cid);
- c.fadeIn(300, function(){ c.show(); }).css('backgroundColor', '');
+ if ( this.cid ) {
+ commentRow = $( '#comment-' + this.cid );
+ }
+
+ /*
+ * When closing the Quick Edit form, show the comment row and move focus
+ * back to the Quick Edit button.
+ */
+ if ( 'edit-comment' === this.act ) {
+ commentRow.fadeIn( 300, function() {
+ commentRow
+ .show()
+ .find( '.vim-q' )
+ .attr( 'aria-expanded', 'false' )
+ .focus();
+ } ).css( 'backgroundColor', '' );
+ }
+
+ // When closing the Reply form, move focus back to the Reply button.
+ if ( 'replyto-comment' === this.act ) {
+ commentRow.find( '.vim-r' )
+ .attr( 'aria-expanded', 'false' )
+ .focus();
}
// reset the Quicktags buttons
@@ -649,14 +671,14 @@ commentReply = {
$('#add-new-comment').css('display', '');
- replyrow.hide();
- $('#com-reply').append( replyrow );
+ replyRow.hide();
+ $( '#com-reply' ).append( replyRow );
$('#replycontent').css('height', '').val('');
$('#edithead input').val('');
- $( '.notice-error', replyrow )
+ $( '.notice-error', replyRow )
.addClass( 'hidden' )
.find( '.error' ).empty();
- $( '.spinner', replyrow ).removeClass( 'is-active' );
+ $( '.spinner', replyRow ).removeClass( 'is-active' );
this.cid = '';
this.originalContent = '';
@@ -960,8 +982,7 @@ $(document).ready(function(){
}
// Quick Edit and Reply have an inline comment editor.
- $( '#the-comment-list' ).on( 'click', '.comment-inline', function (e) {
- e.preventDefault();
+ $( '#the-comment-list' ).on( 'click', '.comment-inline', function() {
var $el = $( this ),
action = 'replyto';
@@ -969,6 +990,7 @@ $(document).ready(function(){
action = $el.data( 'action' );
}
+ $( this ).attr( 'aria-expanded', 'true' );
commentReply.open( $el.data( 'commentId' ), $el.data( 'postId' ), action );
} );
});