From 98dee7a196821106bcdacf4845aa28a6c8ede12b Mon Sep 17 00:00:00 2001 From: barryhughes <3594411+barryhughes@users.noreply.github.com> Date: Wed, 30 Mar 2022 10:53:20 -0700 Subject: [PATCH] Don't trigger beforeunload notice inappropriately (re embedded WP_List_Tables). --- plugins/woocommerce/legacy/js/admin/settings.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/woocommerce/legacy/js/admin/settings.js b/plugins/woocommerce/legacy/js/admin/settings.js index 702b0ae1a19..29276907af6 100644 --- a/plugins/woocommerce/legacy/js/admin/settings.js +++ b/plugins/woocommerce/legacy/js/admin/settings.js @@ -70,8 +70,14 @@ // Edit prompt $( function() { var changed = false; + let $check_column = $( '.wp-list-table .check-column' ); + + $( 'input, textarea, select, checkbox' ).on( 'change', function( event ) { + // Toggling WP List Table checkboxes should not trigger navigation warnings. + if ( $check_column.length && $check_column.has( event.target ) ) { + return; + } - $( 'input, textarea, select, checkbox' ).on( 'change', function() { if ( ! changed ) { window.onbeforeunload = function() { return params.i18n_nav_warning; @@ -80,7 +86,7 @@ } }); - $( '.submit :input' ).on( 'click', function() { + $( '.submit :input, input#search-submit' ).on( 'click', function() { window.onbeforeunload = ''; }); });