WordPress.org

Make WordPress Core

Ticket #15809: garyc40-15809.patch

File garyc40-15809.patch, 1.0 KB (added by garyc40, 3 years ago)

fixed "enter" keypress on both publish date and new category text fields, works in both new / edit for post / page

  • wp-admin/js/post.dev.js

    diff --git wp-admin/js/post.dev.js wp-admin/js/post.dev.js
    index 1c39edf..ec82389 100644
    jQuery(document).ready( function($) { 
    237237 
    238238        postboxes.add_postbox_toggles(pagenow); 
    239239 
     240        // avoid accidentally submitting the whole form by pressing "enter" on these fields 
     241        $('#timestampdiv input[type=text]').submitTarget($('.save-timestamp')); 
     242        $('#newcategory').submitTarget($('#category-add-submit')); 
     243 
    240244        // multi-taxonomies 
    241245        if ( $('#tagsdiv-post_tag').length ) { 
    242246                tagBox.init(); 
  • wp-admin/js/utils.dev.js

    diff --git wp-admin/js/utils.dev.js wp-admin/js/utils.dev.js
    index 30446c1..0c6c819 100644
    function getAllUserSettings() { 
    142142 
    143143        return wpCookies.getHash('wp-settings-' + userSettings.uid) || {}; 
    144144} 
     145 
     146jQuery.fn.submitTarget = function(el) { 
     147        jQuery(this).each(function(){ 
     148                jQuery(this).keydown(function(e){ 
     149                        if (e.keyCode == 13) { console.log(el); 
     150                                el.click(); 
     151                                return false; 
     152                        } 
     153                }); 
     154        }); 
     155}; 
     156 No newline at end of file