Make WordPress Core

Ticket #36854: fix_button_focus_on_reply.patch

File fix_button_focus_on_reply.patch, 3.5 KB (added by MarcDK, 9 years ago)
  • wp-includes/js/comment-reply.js

    From a17aaef53f33d0889e93ff9f4b3b8f33e15d043d Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Marc=20T=C3=B6nsing?= <marc@eatsmarter.de>
    Date: Mon, 16 May 2016 18:07:10 +0200
    Subject: [PATCH] When the user clicks on the comment reply button the focus
     is not longer set on button elements in the comment form.
     This is useful if the user has installed plugins or uses a
     theme where the first element is not the textarea dom
     element.
    
    ---
     wp-includes/js/comment-reply.js     |    4 ++--
     wp-includes/js/comment-reply.min.js |    2 +-
     2 files changed, 3 insertions(+), 3 deletions(-)
    
    diff --git a/wp-includes/js/comment-reply.js b/wp-includes/js/comment-reply.js
    index 184726d..4d0f3df 100644
    a b var addComment = { 
    7575                                        cssHidden = true;
    7676                                }
    7777
    78                                 // Skip form elements that are hidden or disabled.
    79                                 if ( 'hidden' === element.type || element.disabled || cssHidden ) {
     78                                // Skip form elements that are hidden, buttons or disabled.
     79                                if ( 'hidden' === element.type || 'button' === element.type || element.disabled || cssHidden ) {
    8080                                        continue;
    8181                                }
    8282
  • wp-includes/js/comment-reply.min.js

    diff --git a/wp-includes/js/comment-reply.min.js b/wp-includes/js/comment-reply.min.js
    index 4042143..536a6d4 100644
    a b  
    1 var addComment={moveForm:function(a,b,c,d){var e,f,g,h,i=this,j=i.I(a),k=i.I(c),l=i.I("cancel-comment-reply-link"),m=i.I("comment_parent"),n=i.I("comment_post_ID"),o=k.getElementsByTagName("form")[0];if(j&&k&&l&&m&&o){i.respondId=c,d=d||!1,i.I("wp-temp-form-div")||(e=document.createElement("div"),e.id="wp-temp-form-div",e.style.display="none",k.parentNode.insertBefore(e,k)),j.parentNode.insertBefore(k,j.nextSibling),n&&d&&(n.value=d),m.value=b,l.style.display="",l.onclick=function(){var a=addComment,b=a.I("wp-temp-form-div"),c=a.I(a.respondId);if(b&&c)return a.I("comment_parent").value="0",b.parentNode.insertBefore(c,b),b.parentNode.removeChild(b),this.style.display="none",this.onclick=null,!1};try{for(var p=0;p<o.elements.length;p++)if(f=o.elements[p],h=!1,"getComputedStyle"in window?g=window.getComputedStyle(f):document.documentElement.currentStyle&&(g=f.currentStyle),(f.offsetWidth<=0&&f.offsetHeight<=0||"hidden"===g.visibility)&&(h=!0),"hidden"!==f.type&&!f.disabled&&!h){f.focus();break}}catch(q){}return!1}},I:function(a){return document.getElementById(a)}};
    2  No newline at end of file
     1var addComment={moveForm:function(e,t,n,o){var r,i,d,m,l=this,a=l.I(e),c=l.I(n),p=l.I("cancel-comment-reply-link"),s=l.I("comment_parent"),u=l.I("comment_post_ID"),f=c.getElementsByTagName("form")[0];if(a&&c&&p&&s&&f){l.respondId=n,o=o||!1,l.I("wp-temp-form-div")||(r=document.createElement("div"),r.id="wp-temp-form-div",r.style.display="none",c.parentNode.insertBefore(r,c)),a.parentNode.insertBefore(c,a.nextSibling),u&&o&&(u.value=o),s.value=t,p.style.display="",p.onclick=function(){var e=addComment,t=e.I("wp-temp-form-div"),n=e.I(e.respondId);if(t&&n)return e.I("comment_parent").value="0",t.parentNode.insertBefore(n,t),t.parentNode.removeChild(t),this.style.display="none",this.onclick=null,!1};try{for(var y=0;y<f.elements.length;y++)if(i=f.elements[y],m=!1,"getComputedStyle"in window?d=window.getComputedStyle(i):document.documentElement.currentStyle&&(d=i.currentStyle),(i.offsetWidth<=0&&i.offsetHeight<=0||"hidden"===d.visibility)&&(m=!0),"hidden"!==i.type&&"button"!==i.type&&!i.disabled&&!m){i.focus();break}}catch(v){}return!1}},I:function(e){return document.getElementById(e)}};
     2 No newline at end of file