Don't trigger beforeunload notice inappropriately (re embedded WP_List_Tables).

This commit is contained in:
barryhughes 2022-03-30 10:53:20 -07:00
parent 69b6a71ab5
commit 98dee7a196
1 changed files with 8 additions and 2 deletions

View File

@ -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 = '';
});
});