Menus: Remove error styling when the user addresses the error.

An error is triggered if a Menu Name isn't given when the user attempts to create a menu. When they go back and add a name, the error styling can be removed.

Props ashokrd2013, piyush9100, welcher, afercia.
Fixes #42321.


Built from https://develop.svn.wordpress.org/trunk@44680


git-svn-id: http://core.svn.wordpress.org/trunk@44511 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2019-01-21 22:10:49 +00:00
parent b9e6b7e2a3
commit 445209c9eb
4 changed files with 23 additions and 6 deletions

View File

@ -835,6 +835,20 @@
}
}
});
$( '#menu-name' ).on( 'input', _.debounce( function () {
var menuName = $( document.getElementById( 'menu-name' ) ),
menuNameVal = menuName.val();
if ( ! menuNameVal || ! menuNameVal.replace( /\s+/, '' ) ) {
// Add warning for invalid menu name.
menuName.parent().addClass( 'form-invalid' );
} else {
// Remove warning for valid menu name.
menuName.parent().removeClass( 'form-invalid' );
}
}, 500 ) );
$('#add-custom-links input[type="text"]').keypress(function(e){
$('#customlinkdiv').removeClass('form-invalid');
@ -1166,8 +1180,8 @@
menuName = $('#menu-name'),
menuNameVal = menuName.val();
// Cancel and warn if invalid menu name
if( !menuNameVal || menuNameVal == menuName.attr('title') || !menuNameVal.replace(/\s+/, '') ) {
menuName.parent().addClass('form-invalid');
if ( ! menuNameVal || ! menuNameVal.replace( /\s+/, '' ) ) {
menuName.parent().addClass( 'form-invalid' );
return false;
}
// Copy menu theme locations

File diff suppressed because one or more lines are too long

View File

@ -1779,8 +1779,11 @@ function wp_default_scripts( &$scripts ) {
)
);
// Navigation Menus
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox', 'json2' ) );
/*
* Navigation Menus: Adding underscore as a dependency to utilize _.debounce
* see https://core.trac.wordpress.org/ticket/42321
*/
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox', 'json2', 'underscore' ) );
did_action( 'init' ) && $scripts->localize(
'nav-menu',
'navMenuL10n',

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.1-beta1-44679';
$wp_version = '5.1-beta1-44680';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.