From 5c8491c8626c62832de2d347990ac23a51c872cb Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Sat, 14 Nov 2020 15:25:34 -0300 Subject: [PATCH] Remove jQuery code that does nothing This commit replaces a block of jQuery code that I believe does nothing. I found it while starting the work to make our JS code compatible with jQuery 3 as it uses jQuery.fn.keyup() which has been deprecated. As far as I can understand, this block of code is supposed to change the focus to the coupon description when the user hits the tab key while the focus is on the title field. It doesn't work because the keyup event is not fired for the tab key. The current behavior is that when the user hits the tab key, the focus changes to the "Generate coupon code" button, and if the tab key is pressed another time, the focus changes to the description text field. Which seems fine to me and that is why I'm suggesting we remove this code instead of fixing it. I believe it was added in this c15b8e817cb523a5534d935bcb138e47642f76b4 commit six years ago and unfortunatelly the commit doesn't provide much information on why it was added. --- assets/js/admin/meta-boxes.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/assets/js/admin/meta-boxes.js b/assets/js/admin/meta-boxes.js index 13e2c4a56c4..daf756bf17f 100644 --- a/assets/js/admin/meta-boxes.js +++ b/assets/js/admin/meta-boxes.js @@ -16,18 +16,6 @@ jQuery( function ( $ ) { runTipTip(); - // Allow Tabbing - $( '#titlediv' ).find( '#title' ).keyup( function( event ) { - var code = event.keyCode || event.which; - - // Tab key - if ( code === '9' && $( '#woocommerce-coupon-description' ).length > 0 ) { - event.stopPropagation(); - $( '#woocommerce-coupon-description' ).focus(); - return false; - } - }); - $( '.wc-metaboxes-wrapper' ).on( 'click', '.wc-metabox > h3', function() { $( this ).parent( '.wc-metabox' ).toggleClass( 'closed' ).toggleClass( 'open' ); });