WordPress.org

Make WordPress Core

Changeset 40094


Ignore:
Timestamp:
02/21/17 06:51:47 (5 weeks ago)
Author:
dd32
Message:

Customize: Trim whitespace from nav menu item titles so that the underlying object's original title appears as input placeholder and in the control's title.

Whitespace is trimmed from titles in PHP when saved in any case, so this aligns the client-side behavior with what happens on the server.

Amends [38618].
Merges [39994] to the 4.7 branch.
See #38015.
Fixes #39600.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-admin/js/customize-nav-menus.js

    r39570 r40094  
    15101510         */ 
    15111511        _setupTitleUI: function() { 
    1512             var control = this; 
    1513  
     1512            var control = this, titleEl; 
     1513 
     1514            // Ensure that whitespace is trimmed on blur so placeholder can be shown. 
     1515            control.container.find( '.edit-menu-item-title' ).on( 'blur', function() { 
     1516                $( this ).val( $.trim( $( this ).val() ) ); 
     1517            } ); 
     1518 
     1519            titleEl = control.container.find( '.menu-item-title' ); 
    15141520            control.setting.bind( function( item ) { 
     1521                var trimmedTitle, titleText; 
    15151522                if ( ! item ) { 
    15161523                    return; 
    15171524                } 
    1518  
    1519                 var titleEl = control.container.find( '.menu-item-title' ), 
    1520                     titleText = item.title || item.original_title || api.Menus.data.l10n.untitled; 
     1525                trimmedTitle = $.trim( item.title ); 
     1526 
     1527                titleText = trimmedTitle || item.original_title || api.Menus.data.l10n.untitled; 
    15211528 
    15221529                if ( item._invalid ) { 
     
    15251532 
    15261533                // Don't update to an empty title. 
    1527                 if ( item.title || item.original_title ) { 
     1534                if ( trimmedTitle || item.original_title ) { 
    15281535                    titleEl 
    15291536                        .text( titleText ) 
Note: See TracChangeset for help on using the changeset viewer.