WordPress.org

Make WordPress Core

Changeset 47294


Ignore:
Timestamp:
02/16/2020 06:25:54 AM (7 months ago)
Author:
SergeyBiryukov
Message:

Menus: Restore the title of the currently active/expanded menu item when clicking "Cancel" after editing.

Other inputs are already restored to their previous values in that case.

Props Girishpanchal, nilamacharya, JoshuaWold, welcher, SergeyBiryukov.
Fixes #43031.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/lib/nav-menu.js

    r47122 r47294  
    11631163            var settings, item,
    11641164            matchedSection = /#(.*)$/.exec(clickedEl.href);
     1165
    11651166            if ( matchedSection && matchedSection[1] ) {
    11661167                settings = $('#'+matchedSection[1]);
     
    11871188            var settings = $( clickedEl ).closest( '.menu-item-settings' ),
    11881189                thisMenuItem = $( clickedEl ).closest( '.menu-item' );
    1189             thisMenuItem.removeClass('menu-item-edit-active').addClass('menu-item-edit-inactive');
    1190             settings.setItemData( settings.data('menu-item-data') ).hide();
     1190
     1191            thisMenuItem.removeClass( 'menu-item-edit-active' ).addClass( 'menu-item-edit-inactive' );
     1192            settings.setItemData( settings.data( 'menu-item-data' ) ).hide();
     1193            // Restore the title of the currently active/expanded menu item.
     1194            thisMenuItem.find( '.menu-item-title' ).text( settings.data( 'menu-item-data' )['menu-item-title'] );
     1195
    11911196            return false;
    11921197        },
     
    11961201            menuName = $('#menu-name'),
    11971202            menuNameVal = menuName.val();
     1203
    11981204            // Cancel and warn if invalid menu name.
    11991205            if ( ! menuNameVal || ! menuNameVal.replace( /\s+/, '' ) ) {
     
    12241230        eventOnClickMenuItemDelete : function(clickedEl) {
    12251231            var itemID = parseInt(clickedEl.id.replace('delete-', ''), 10);
     1232
    12261233            api.removeMenuItem( $('#menu-item-' + itemID) );
    12271234            api.registerChange();
Note: See TracChangeset for help on using the changeset viewer.